Skip to content
Discussion options

You must be logged in to vote

You can't use JavaScript in Antlers tags because it's rendered before it gets sent to the browser. JavaScript doesn't have a chance to touch it.

I guess you could output everything through Antlers and use some logic in your Javascript to display the right one.

Using Alpine.js as an example here. This Antlers code...

{{ locations }}
  <p x-if="location == '{{ name }}'">{{ name }}</p>
{{ /locations }}

would render...

  <p x-if="location == 'one'">one</p>
  <p x-if="location == 'two'">two</p>
  <p x-if="location == 'three'">three</p>

Then Alpine would display the right one.

Although something tells me this is also not a great solution. Maybe more details about what you're doing would be he…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@cmorierroy
Comment options

@jasonvarga
Comment options

@cmorierroy
Comment options

@jasonvarga
Comment options

Answer selected by cmorierroy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants