slim-template / slim

Slim is a template language whose goal is to reduce the syntax to the essential parts without becoming cryptic.
https://slim-template.github.io
MIT License
5.29k stars 500 forks source link

How can I set <script> attribute? #916

Closed josemateuss closed 1 year ago

josemateuss commented 1 year ago

I'd like to use nonce script like this in HTML:

<script nonce="<%= @nonce %>">
  // your inline script here
</script>

But I couldn't get it to work using Slim, could someone help me?

My slim code:

javascript:
   alert('Slim supports embedded javascript!')
minad commented 1 year ago
javascript[nonce=@nonce]:
   alert('Slim supports embedded javascript!')
josemateuss commented 1 year ago

@minad Hi, It didn't work here, it's giving a syntax error, I'm using version 3.0.8 of slim, could that be the reason?

minad commented 1 year ago

Could be. Please check the newest version.

josemateuss commented 1 year ago

error: Slim::Parser::SyntaxError

minad commented 1 year ago

See here:

https://github.com/slim-template/slim/blob/aec542502566680f3e3c4196581218445441211b/CHANGES#L33-L35

josemateuss commented 1 year ago

The problem was the version, thanks so much.