Skip to content

locals can only be JSON string #70

@cossssmin

Description

@cossssmin

Consider {{ title }} is a string equal to test.

<!-- include.html -->
<p>The title in the include is: {{ title }}</p>
<!-- test.html -->
<p>The title is: {{ title }}</p>
<include src="include.html" locals="{{ title }}"></include>

Result: SyntaxError: Unexpected token { in JSON at position 1

These won't work, either:

<include src="include.html" locals=locals='{"title": {{ title }} }'></include>

<include src="include.html"  locals='{{ {"title": title } }}'></include>

<include src="include.html"  locals='{"title": title }'></include>

Would be awesome if you could pass expressions variables inside the locals="" attribute - sometimes you need to pass in something that has a dynamic/computed value, so you can't write it out by hand.

Any ideas?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions