hygen
hygen copied to clipboard
Nested variable in conditional rendering raises error
I'm trying to prevent a template generation for a certain condition:
---
to: "<%= locals.image ? 'apps/operations/<%= h.inflection.pluralize(name) %>/image.rb' : null %>"
---
There's a nested template literal in the file location. Running the generator raises the following error: Error: Could not find matching close tag for "<%=".
It looks like an invalid ejs syntax. The documentation does not cover nested variable in a conditional rendering. How to solve this problem?
Something like this should work:
---
to: "<%= locals.image ? 'apps/operations/' + h.inflection.pluralize(name) + '/image.rb' : null %>"
unless_exists: true
---
Even better:
to: "<%= locals.image ? `apps/operations/${h.inflection.pluralize(name)}/image.rb` : null %>"
This is such a common thing in template generation that I think a simpler option like skip_if
will be very handy.
Hi,
I am having the same issue with
---
to: "<%= group === 'panels' ? 'src/client/app/components/<%= group %>/<%= Name %>/stores/<%= name %>Store.js' : null %>"
unless_exists: true
---
Error: Could not find matching close tag for "<%=".
Hygen v4.0.11
I do not need to use pluralize in this case, I just need to apply the variables in the path :( . Any idea>?
haven't found anything in the docs
You're nesting ejs tags, instead use regular js
---
to: "<%= group === 'panels' ? `src/client/app/components/${group}/${Name}/stores/${name}Store.js` : null %>"
unless_exists: true
---
Hi,
I am having issue on
Exception Message: {"metadata":{"error":true},"payload":{"code":412,"errors":[],"message":"Invalid nesting of ocx_if and ocx_loop"}}
Could you please help?