Closed qubitrenegade closed 1 year ago
I'm of a few minds on this. I think making it letters would be a good way to delineate between string and numeric comparison. e.g.:
eq
- equalne
- not equallt
- less thangt
- greater thanI'm not sure what lt/gt would mean as far as string comparison, and maybe for string comparison it's just eq
and ne
(or eql
and neq
), because then we don't need a "less/greater than or equal to" string comparison operator (which again, I struggle to think of a sane "less than" comparison of strings... alphabetical?)
This provides good delineation from mathematic operators, e.g.:
==
- numeric equal!=
- numeric not equal>=
greater than or equal toIn other languages there's been some confusion between string and numeric operator precedence, and in other languages the overloading of operators causes further confusion. I think be defining "use these to compare numbers, use these to compare strings" we provide obvious segregation between functions and their expected behavior.
Anyway, I'm mostly just thinking out loud.
I suspect the syntax here has to change, since we would be dealing with adding helpers that have to be functions. It would be something more like if Eq(a, b)
.
This would be tough. Something like this thread is theoretically possible, but we would need to understand the types of the values in Rust.
Now that Rust's ecosystem is more mature, if we really want a more fully featured language, we should consider Tera: https://tera.netlify.com/
+1 for looking into something like Tera... I've never been a huge fan of Handlebars and its limitations.
another option would be getting something like duktape embedded, and then using real Handlebars. It would make it easier to do dynamic extension.
According to documentation: https://docs.rs/handlebars/1.1.0/handlebars/#built-in-helpers
eq
must be build-in helper. But it doesn't work: Error rendering "index.html" line 24, col 7: Helper not defined: "eq"
Lacking of basic functions in templating. Working with habitat templates makes me cry ;(
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.
I'd argue that this is still valid if not high priority...
On Sat, Apr 4, 2020 at 7:49 PM stale[bot] notifications@github.com wrote:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/habitat-sh/habitat/issues/5077#issuecomment-609115574, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSBHCI27WKGOUSZDA64KPTRK7PRPANCNFSM4E77D36A .
New rust handlebars library has embedded compare helpers: https://docs.rs/handlebars/3.0.1/handlebars/#built-in-helpers
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.
This issue has been automatically closed after being stale for 400 days. We still value your input and contribution. Please re-open the issue if desired and leave a comment with details.
How to Reproduce
Attempt to compare two strings using handlebar helpers:
(Syntax error)
(always evaluates statement inside unless clause)
Expected Output
Should not evaluate anything inside the "unless" clause.
More likely this would be used when comparing svc or package variables. The use case I imagined was:
I think this particular use case would be better solved with a different helper, but it still serves as a good example of string that we may want to compare in a plan.
Thanks!