-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* translate encodeHTMLSource * porting 1.1.1 * update test case * comment print * use Union
- Loading branch information
David Chen
authored
May 3, 2023
1 parent
1eae420
commit 6d3bfe4
Showing
14 changed files
with
125 additions
and
126 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 was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
src/doT/tests/__snapshots__/test_dot/test_template[arrays.tmpl].json
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 @@ | ||
"function anonymous(it) {var out='';var arr1=it.array;if(arr1){var value,index=-1,l1=arr1.length-1;while(index<l1){value=arr1[index+=1];out+='\n<div>'+(value)+'!</div>\n';} } out+='';return out;}" |
1 change: 1 addition & 0 deletions
1
src/doT/tests/__snapshots__/test_dot/test_template[conditionals.tmpl].json
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 @@ | ||
"function anonymous(it) {var out='';if(it.name){out+='\n<div>Oh, I love your name, '+(it.name)+'!</div>\n';}else if(it.age === 0){out+='\n<div>Guess nobody named you yet!</div>\n';}else{out+='\nYou are '+(it.age)+' and still don\\'t have a name?\n';}out+='';return out;}" |
1 change: 1 addition & 0 deletions
1
src/doT/tests/__snapshots__/test_dot/test_template[encode.tmpl].json
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 @@ | ||
"function anonymous(it) {var out='Visit '+(it.uri)+'';return out;}" |
1 change: 1 addition & 0 deletions
1
src/doT/tests/__snapshots__/test_dot/test_template[evaluation.tmpl].json
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 @@ | ||
"function anonymous(it) {var out=''; for(var prop in it) { out+='\n<div>'+(prop)+'</div>\n'; } out+='';return out;}" |
1 change: 1 addition & 0 deletions
1
src/doT/tests/__snapshots__/test_dot/test_template[interpolation.tmpl].json
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 @@ | ||
"function anonymous(it) {var out='<div>Hi '+(it.name)+'!</div>\n<div>'+(it.age || '')+'</div>';return out;}" |
1 change: 1 addition & 0 deletions
1
src/doT/tests/__snapshots__/test_dot/test_template[issue_4.tmpl].json
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 @@ | ||
"function anonymous(it) {var out='';if(it.options == 1){out+='Option 1';}else if(it.options == 2){out+='Option 2';}else{out+='Other option';}out+=':\n\nMore text';return out;}" |
1 change: 1 addition & 0 deletions
1
src/doT/tests/__snapshots__/test_dot/test_template[partials.tmpl].json
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 @@ | ||
"function anonymous(it) {var out='';##def.snippet: <div>'+(it.name)+'</div>{{#def.jokeout+='\n#}}\n\n';#def.snippetout+='';return out;}" |
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,7 @@ | ||
import pytest | ||
from syrupy.extensions.json import JSONSnapshotExtension | ||
|
||
|
||
@pytest.fixture | ||
def snapshot_json(snapshot): | ||
return snapshot.use_extension(JSONSnapshotExtension) |
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 |
---|---|---|
@@ -1,16 +1,22 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
from syrupy.extensions.json import JSONSnapshotExtension | ||
|
||
from .. import template, template_settings | ||
|
||
|
||
@pytest.fixture | ||
def snapshot_json(snapshot): | ||
return snapshot.use_extension(JSONSnapshotExtension) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"case", (Path(__file__).parent / "test_dot").glob("*.tmpl"), ids=lambda x: x.name | ||
) | ||
def test_template(snapshot, case: Path): | ||
def test_template(snapshot_json, case: Path): | ||
setting = template_settings._replace(strip=False) | ||
|
||
with case.open("r", encoding="utf-8") as ifile: | ||
_template = ifile.read() | ||
assert snapshot == template(_template, setting) | ||
assert snapshot_json == template(_template, setting) |
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,3 @@ | ||
{{ for(var prop in it) { }} | ||
<div>{{=prop}}</div> | ||
{{ } }} |
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 |
---|---|---|
@@ -1,8 +1,2 @@ | ||
<div>Hi { | ||
{=it.name | ||
} | ||
}!</div> | ||
<div>{ | ||
{=it.age || '' | ||
} | ||
}</div> | ||
<div>Hi {{=it.name}}!</div> | ||
<div>{{=it.age || ''}}</div> |