Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is assignment within templates discouraged? #201

Open
cxw42 opened this issue Jan 20, 2020 · 1 comment
Open

Why is assignment within templates discouraged? #201

cxw42 opened this issue Jan 20, 2020 · 1 comment

Comments

@cxw42
Copy link

cxw42 commented Jan 20, 2020

Assignment within templates is forbidden in Kolon and discouraged by the docs for TTerse. Why is that? The only explanation I have found is a comment that it was for the sake of simplicity.

Context: I am looking for a sandboxed DSL in which people can implement business logic. The target users of the DSL are not Perl programmers, so Safe is not an option, and neither are many of the other template engines (e.g., Text::MicroTemplate, referenced in the linked comment). TTerse looks like it might do the job very nicely! However, I would like to understand whether assignment is at risk of disappearing in a future release before committing to TTerse.

Thank you in advance for your insights!

@hadjiprocopis
Copy link

I have similar issue here with Text::Xslate (via Perl and Mojolicious).

I can do this:

my $arr=[1,2,3];

but I can not do this :

$arr[1] = 12;

I can do this:

my $y = {a=>1,b=>2};

But I can not do this:

$y['c'] = 3;

or even this:

$y['a'] = 3;

All is forbidden!

After hearing so much about Text::Xslate I thought I give it a try. And after converting all my templates to this system, BAM! it hits me Forbidden, Forbidden, Forbidden.

Can anyone shed any light on this? I am in the middle of a project and just found out my car has triangular wheels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants