Skip to content

Commit a20f550

Browse files
authored
EXPERIMENTAL: Add Handlebars Support (#32)
Prototyping and exploration of what Handlebars would look likein. Handlebars.Net as the supported engine Handlebar content can be rendered using files with `.hbs` extension in VSCode extension. Enables nested JSON types in the attributes to support more complex attributes
1 parent ed70dea commit a20f550

28 files changed

+300
-34
lines changed

src/Sage.Engine.Tests/CompilerTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ public void TestAssemblyGeneration(string sourceFile)
4545
}
4646

4747
[Test]
48+
[TestCase("%%=ADD(1,2)=%%", ContentType.Handlebars, "%%=ADD(1,2)=%%")]
4849
[TestCase("%%=ADD(1,2)=%%", ContentType.AMPscript, "3")]
50+
[TestCase("{{#if true}}Hello{{/if}}", ContentType.AMPscript, "")]
51+
[TestCase("{{#if true}}Hello{{/if}}", ContentType.Handlebars, "Hello")]
4952
public void TestRenderer(string input, ContentType type, string expected)
5053
{
5154
var content = new EmbeddedContent(input, "TEST", "TEST", 1, type);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"people": [
3+
{
4+
"name": "Adam"
5+
},
6+
{
7+
"name": "Howard"
8+
}
9+
]
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
===========
2+
eachHelper
3+
===========
4+
{{#each people}}<h1>{{name}}</h1>{{/each}}
5+
++++++++++
6+
<h1>Adam</h1><h1>Howard</h1>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"isActiveFalse": false,
3+
"isActiveTrue": true
4+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
===========
2+
If True Block
3+
===========
4+
{{#if isActiveTrue}}hello{{else}}world{{/if}}
5+
++++++++++
6+
hello
7+
===========
8+
If False Block
9+
===========
10+
{{#if isActiveFalse}}hello{{else}}world{{/if}}
11+
++++++++++
12+
world
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"titleTags": "First Template <p> Tags",
3+
"titleNoTags": "First Template No Tags"
4+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
===========
2+
Escaping
3+
===========
4+
{{titleTags}}
5+
++++++++++
6+
First Template &lt;p&gt; Tags
7+
===========
8+
No Escaping
9+
===========
10+
{{titleNoTags}}
11+
++++++++++
12+
First Template No Tags
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"isActiveTrue": true,
3+
"isActiveFalse": false
4+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
===========
2+
Unless Helper False
3+
===========
4+
{{#unless isActiveFalse}}hello{{/unless}}
5+
++++++++++
6+
hello
7+
===========
8+
Unless Helper True
9+
===========
10+
{{#unless isActiveTrue}}hello{{/unless}}
11+
++++++++++
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"primary": {
3+
"name": "Adam"
4+
},
5+
"name": "Howard"
6+
}

0 commit comments

Comments
 (0)