-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handlebars template exec function calling with kcl json value (#…
…1457) Signed-off-by: peefy <[email protected]>
- Loading branch information
Showing
4 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import template | ||
|
||
_data = { | ||
name = "handlebars", | ||
v = [ { a = 1}, { a = 2}], | ||
c = { d = 5}, | ||
g = { b = [{ aa = { bb = 55}}, { aa = { bb = 66} } ] }, | ||
people = [ "Yehuda Katz", "Alan Johnson", "Charles Jolley" ] | ||
} | ||
|
||
content = template.execute("""\ | ||
Hello world from {{name}} | ||
|
||
{{#each v}} | ||
{{this.a}} | ||
{{/each}} | ||
{{ c.d }} | ||
{{#each people}} | ||
{{ this }} | ||
{{/each}} | ||
{{#each g.b}} | ||
{{this.aa.bb}} | ||
{{/each}} | ||
""", _data) | ||
|
||
content_raw = template.execute("""\ | ||
{{this.name}} | ||
{{this.v}} | ||
{{this.c}} | ||
{{this.g}} | ||
{{this.people}} | ||
""", _data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
content: | | ||
Hello world from handlebars | ||
|
||
1 | ||
2 | ||
5 | ||
Yehuda Katz | ||
Alan Johnson | ||
Charles Jolley | ||
55 | ||
66 | ||
content_raw: | | ||
handlebars | ||
[[object], [object]] | ||
[object] | ||
[object] | ||
[Yehuda Katz, Alan Johnson, Charles Jolley] |