Skip to content

Cannot use variable without reassignment #21

@thetutlage

Description

@thetutlage

Originally reported - adonisjs/view#16

When rendering, a state with youtubeUrl variable is passed to the template. I can render it:

{{ youtubeUrl }}

But, if I try usse it like JS variable then I get fail

{{ new URL(youtubeUrl).pathname }} // 500: youtubeUrl is not defined
@set('obj',  new URL(youtubeUrl)) // 500: youtubeUrl is not defined

As a workaround, I have to reassign this variable to itself or another variable

@set('youtubeUrl', youtubeUrl)

{{ new URL(youtubeUrl).pathname }} // ok
@set('obj',  new URL(youtubeUrl)) // ok

Package version

"@adonisjs/core": "5.7.5",
"@adonisjs/view": "6.1.3",

Node.js and npm version

8.3.1

Metadata

Metadata

Assignees

Labels

Type: BugThe issue has indentified a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions