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

Complex logic for conditionals #20

Open
kethinov opened this issue May 22, 2014 · 0 comments
Open

Complex logic for conditionals #20

kethinov opened this issue May 22, 2014 · 0 comments
Assignees
Labels
enhancement Planned feature

Comments

@kethinov
Copy link
Member

kethinov commented May 22, 2014

HTML grammar doesn't permit things like:

<if location="homepage" or location="about" or location="etc">

This is because location is an attribute that is being duplicated on the same element multiple times.

To achieve this style of boolean logic, we need a new syntax that can evaluate JavaScript expressions directly:

<if eval="model.location === 'homepage' || model.location === 'about' || model.location === 'etc'">

Same for one-line ifs:

<!-- Returns true if location is homepage, about, or etc. -->
<p if-eval="model.location === 'homepage' || model.location === 'about' || model.location === 'etc'" true="class='shown'" false="class='hidden'">One-line if.</p>

Implementing this would also allow us to close:

While implementing this, be sure to use eval('(expression)') to limit the potential for arbitrary code execution. Wrapping eval statements in parenthesis should limit the execution merely to evaluating conditionals to some degree.

A related thing to consider is adding <script eval> to let Teddy just execute scripts. If you need to do that, it probably means you're coding a template in a badly designed app, so I would rather encourage the developer to refactor things than give Teddy a way to sidestep technical debt. However it might possibly be worth implementing it as an off by default feature that has to be turned on with settings perhaps.

See also https://macarthur.me/posts/with

@kethinov kethinov added the blocked Cannot be worked on until other issues / PRs are resolved label Jul 24, 2015
@kethinov kethinov removed the blocked Cannot be worked on until other issues / PRs are resolved label Feb 5, 2017
@kethinov kethinov self-assigned this Feb 12, 2017
@kethinov kethinov removed the P4 Low Priority label Mar 21, 2017
@kethinov kethinov added the enhancement Planned feature label Aug 1, 2019
@kethinov kethinov removed their assignment May 23, 2020
@kethinov kethinov self-assigned this Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Planned feature
Development

No branches or pull requests

2 participants