Pass HTML element in Jade variable

Asked

Viewed 220 times

3

Below I have a call from a include to an "Alert", I wonder if it is possible within the message variable not to pass pure HTML () and yes a call #[Strong Well done! ] which is most common within the Jade processor.

- var type = 'success'
- var message = '<strong>Bem feito!</strong> Você lê com sucesso esta mensagem de alerta importante.'

div(class='alert alert-#{type} alert-dismissible', role='alert')
  button.close(type='button', data-dismiss='alert')
    span(aria-hidden='true') &#215;
    span.sr-only Fechar
  != message

1 answer

3


The solution I can think of is to make this message an array and use so:

- var type = 'success'
- var message = ['Bem feito!', 'Você lê com sucesso esta mensagem de alerta importante.']

div(class='alert alert-#{type} alert-dismissible', role='alert')
    button.close(type='button', data-dismiss='alert')
        span(aria-hidden='true') &#215;
        span.sr-only Fechar
    strong #{message[0]}#{' '}
    | #{message[1]}

In this way calls the 'Bem feito!' within the Strong and the rest out. HTML looks like this:

<div role="alert" class="alert alert-success alert-dismissible">
    <button type="button" data-dismiss="alert" class="close">
        <span aria-hidden="true">&#215;</span><span class="sr-only">Fechar</span>
    </button>
    <strong>Bem feito! </strong>Você lê com sucesso esta mensagem de alerta importante.
</div>
  • 1

    That’s not exactly what I need, but it’s a solution. Thank you!

  • @Brunobatist can/wants to ask a new question specifying better what you are looking for?

  • 1

    You don’t need @Sergio if you can find the solution that I want to put here, but at the moment this solution saves me. Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.