Comments (8)
Ok, we tested default
filter only as jg_default
.
I've added example/samples/filter_default.{jingoo, expected}
.
from jingoo.
Seems a little bit hackish but if it works it is better than without the hack, thanks for taking care of this 👍
But this issue highlight another question:
Should jingoo:
- rely on a reserved keywords list
- or should we be able to define some macro/functions which use a name wich is a keyword otherwise.
i.e. should this be allowed?
{% function switch (b) %}{{ not b }}{% endfunction %}
{{ switch (true) }}
I think that 2
would be preferable and should be pretty easy to achieve but I did not try to implement it (yet?).
from jingoo.
Fortunately, the only difference between default(in switch case statement) and default(as filter) is that only latter is followed by LPAREN.
So I've treated the default filter as special ApplyExpr
in jg_parser.mly
.
All test work fine, but if there is something wrong, point it to me.
from jingoo.
Hmm, my fix doesn't work in set
statement...
{{ set baz = default('baz', null) }}
It causes
Jingoo.Jg_types.SyntaxError("Error line 3, col 6, token set ()")
from jingoo.
Sorry, with my quick fix, we'll have to fix everything where ApplyExpr
comes up in jg_parlser.mly
.
This fix doesn't look good, so I'll revert it.
EDIT:
Oh, my example code was wrong! After fixing, test works fine!
-{{ set baz = default('baz', null) }}{{ baz }}
+{% set baz = default('baz', null) %}{{ baz }}
from jingoo.
Okay, apparently this problem wasn't as easy as I thought it would be.
It would certainly be better to be able to use keywords in functions, macro.
But to use keyword like switch
, default
in various context, maybe we have to find out whether the token is keyword or identifier in the lexer context after all, but it's too hard task for me.
By the way, the reason I've added this fix in a rough way is that I'm using default
filter myself in my web site, haha.
(And maybe many devs are using default
filter because it's a useful filter)
from jingoo.
I'd like to be able to declare functions that is using keyword in the future, but the default filter seems to have a big impact, so for now, I'm going to release this fix (although which isn't very good).
When you have time, feel free to remove my fix, and implement your own!
from jingoo.
(And maybe many devs are using
default
filter because it's a useful filter)
That's how I found the bug :)
I'd like to be able to declare functions that is using keyword in the future, but the default filter seems to have a big impact, so for now, I'm going to release this fix (although which isn't very good).
When you have time, feel free to remove my fix, and implement your own!
I'll try to implement a general fix 👍
from jingoo.
Related Issues (20)
- null == null? HOT 2
- Functions and block statements HOT 1
- In Jingoo.Jg_template, provide a function for the getting variables HOT 33
- Use symbolic HTML entities rather than character codes for escaping HOT 5
- Too many frames created HOT 5
- PPX to generate typed TObj from records HOT 1
- No way to set models in built-in executable HOT 2
- May I ask how to do list appending on version 1.2.21 HOT 3
- Is there a way to pass data into template HOT 3
- urlencode filter HOT 2
- Usefulness of mutex? HOT 7
- Release trouble about jingoo 1.3.0 HOT 2
- {% switch %} statement HOT 13
- Tests / Filters HOT 1
- Tset status HOT 5
- Truncated function expansion HOT 9
- Anonymous functions HOT 1
- Proposal: += operator HOT 1
- else if HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jingoo.