-
Notifications
You must be signed in to change notification settings - Fork 5
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
add support for combinatory logic in data-if and data-else #17
Comments
It would be nice to have. I'd also like to compare variables / literals using something like Unfortunately, this could introduce a lot of complexity when building the server-side implementations, and Ideally I want to keep those simple enough that a developer could conceivable build one in a couple of weekends. On the other hand, keeping the implementation simple pushes complexity out to either side (both in preparing the data for the template server-side, and in handling the events and re-rendering client-side). This means more code duplication in your web application. A smarter template syntax would reduce that. There is a tension between these two objectives. I think we're still finding the right balance. I suggest we keep the simple syntax we have and highlight cases where it's causing code duplication. Then we should try to come up with the easiest to implement syntax that will solve those. I don't think we should build new syntax for combinatory logic or equality checks without a clear case of difficult to avoid code duplication. |
Here is the exemple that made me think about this
Each todo item has a done flag. |
I can see three proposition. {
todos: [...],
visibleTodos: [...],
showDoneTodos: true
} When the flag showDoneTodos change, we recompute the visible todos. Another proposition: <app-todo data-if="isTodoVisible(todo.id)"></app-todo> Thoses functions would be a third parameter to rendering (after data, and handlers). And finally you sayed that implementing this kind of logic can make it a lot harder to implement a server side. But if we limit well enougth the set of operator (e.g. ! == && || and parenthesis) (like angularjs did) it should be quite easy to implement in most C familly language (javascript, c, java) which share most of these operator anyway. I've seen you're building a scheme implementation, maybe on a lisp it will be harder because of the distance between theses expression and the way it's expressed on a lisp. Anyway, I would be happy to read you thought on this. |
I still agree with you, we need a strong case before doing anything. What if we expose a couple of simple function, like and() not() or(), eq() and those are the only function authorized. This way it would be way easier to implement, we just need a simple set of function, and combine this with littéral and escaped varaible |
Ideally, I'd also like us to come up with a solution for if/else and if-equal (or similar). It's difficult to keep the syntax sane though. As you say, the combinatory logic is probably the easiest part. |
Here is my proposition:
We don't allow any type of function. Just a limited set which are provided by the runtime module (the same that is called to extract value from data). That way we could quickly add new function, without making the compiler more and more complex. The syntaxe is the normal js function call.
maybe what can be added
Usage of any other symbol will provoke a compilation error. |
Why don't we use the hard work done by other. Let's say we have a jsonql implementation inside each magery implementation ? I don't point you in the direction of this project in particular, just this kind of projet, maybe it's abandonned. I don't kown. |
Looking at existing implementations is a good idea and jsonql looks pretty nice. Even though it's more complicated to implement I have to say I like the traditional |
It's been a year, but i still want to help on this one I've started a projet https://github.com/benzen/simple-el-parser-test-suite. My hope is to define a simple expression language that very implementation of magery could use. Let me know if the Idea seems logical to you, and if the target AST would be suffisiant (as a starting point) |
Also I've implmented a parser for this very simple expression language: In my opinion it will be very straightforward to make an equivalent implementation in javascript |
This is looking nice. Not too complicated. It will be interesting to see how much code it adds to my python implementation. If it's complicated perhaps we could have it as an optional extra for server-side implementations. |
The way I see this is that the parser should be a separate package, just because it’s a specialized task. But I don’t see my self using a templating system without this piece ( or something providing an equivalent functionality).
After converting the python templating system into groovy I think this conversion will be close to 1 to 1 conversion too.
Let’s keep in touch ;)
Benjamin Dreux
… Le 4 janv. 2019 à 07:20, Caolan McMahon ***@***.***> a écrit :
This is looking nice. Not too complicated. It will be interesting to see how much code it adds to my python implementation. If it's complicated perhaps we could have it as an optional extra for server-side implementations.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
In most template system i've used, if/else/unless operators support some way of combinatory logic.
Do you plan on supporting more complexe expression on data-if and data-else, or is it a choice ?
The text was updated successfully, but these errors were encountered: