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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Own template engine 馃 #6

Open
1 of 7 tasks
Ethosa opened this issue Apr 2, 2023 · 1 comment
Open
1 of 7 tasks

Own template engine 馃 #6

Ethosa opened this issue Apr 2, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@Ethosa
Copy link
Contributor

Ethosa commented Apr 2, 2023

Example syntax:

  • {{variableName}} for variables
  • {| if condition |} ... {| end |} for if stmt
  • {| elif condition |} ... {| end |} for elif stmt
  • {| else |} ... {| end |} for else stmt
  • {| for item in array|} ... {| end |} for for stmt
  • {{variableName + otherVariable}} for evaluate
  • {| func name(arg1, arg2, ...) |} ... {| end |} and {{ name(arg1, arg2, ...)}} for functions
@Ethosa Ethosa added the enhancement New feature or request label Apr 2, 2023
@Ethosa Ethosa self-assigned this Apr 2, 2023
@Ethosa Ethosa changed the title Own template engine Own template engine 馃 May 18, 2023
@quimt
Copy link

quimt commented Jun 25, 2023

I'm partial to systems that emphasize functions of text and allow for nesting. I have some familiarity with Pollen, as an example:

鈼妚ariable-name
鈼妕ag{Text聽inside聽the聽tag.}
鈼妕ag[#:attr聽"value"]{Text聽inside聽the聽tag}
鈼奼et-customer-id["Brennan聽Huff"]
鈼妕ag{His聽ID聽is聽鈼奼et-customer-id["Brennan聽Huff"].}

The goal of the syntax is to allow procs that return strings to extend html tags, and to modify paragraph text at any level of nesting. This helps the coded text to more closely resemble the output text. Like a lot of things that have become standards on the front end, mustache-style syntax spreads easily, and is easy to implement on JS, but ultimately it's not as powerful a tool as it could be, and is not even that easy to implement in languages where whitespace is part of the syntax.

I'd rather have this kind of function injection on parts of template strings than all the nimja-style constructs. These are nice, but their functionality is easy to get if you can easily inline procs of parts of the text.

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

No branches or pull requests

2 participants