Expandir minha barra de realizações na Comunidade.

Mark Solution

Esta conversa foi bloqueada devido à inatividade. Crie uma nova publicação.

SOLUCIONADO

Access Sightly Variable In HandleBars

Avatar

Level 5

Hi,

I have the html file in which I am getting the variable as using below statement:

<sly data-sly-test.myVal=${some exp} />

And I want to use myVal in the hbs template under same file like below.

{{#each Obj}}

     {{#if myVal == 'bla'}}

          <img/>

     {{}}

{{/each}}

Thanks,

1 Solução aceita

Avatar

Resposta correta de
Employee

I don't think the contexts here are shared. So perhaps what you can do is to write JS-vars, and use these in handlebars?

Ver solução na publicação original

4 Respostas

Avatar

Resposta correta de
Employee

I don't think the contexts here are shared. So perhaps what you can do is to write JS-vars, and use these in handlebars?

Avatar

Level 2

Hi,

You can use the sightly variable in the handlebars by adding @context='scriptString', as shown in the below example

{{#if ${myVal ==  'bla' @context='scriptString'}}}

              //something

            {{/if}}

Avatar

Employee

This to me looks not like a valid syntax.

Avatar

Level 2

I have tested it. This is working fine for me.