Created
April 10, 2013 20:49
-
-
Save fils/5358320 to your computer and use it in GitHub Desktop.
Demonstration of an issue I am seeing with Dart Mustache templating
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
import 'package:mustache/mustache.dart' as mustache; | |
void main() { | |
var legSet = [{'legnumber': 207, 'is_last': false}, {'legnumber': 208, 'is_last': false}, {'legnumber': 209, 'is_last': false}, {'legnumber': 210, 'is_last': true}]; | |
var source = (""" | |
SELECT DISTINCT ?slice | |
FROM <http://data.oceandrilling.org/janus/> | |
WHERE { | |
{{#legs}} { ?sliceKey iodp:leg "{{legnumber}}" . } {{^is_last}} UNION {{/is_last}} {{/legs}} | |
?sliceKey iodp:site "1226" . | |
?slice qb:sliceStructure <http://data.oceandrilling.org/janus/sliceByvcd_image> . | |
?slice qb:sliceStructure ?sliceKey . | |
} | |
"""); | |
var template = mustache.parse(source); | |
var output = template.renderString({'legs': legSet}); | |
print(output); | |
var source2 = (""" | |
SELECT DISTINCT ?slice | |
FROM <http://data.oceandrilling.org/janus/> | |
WHERE ( | |
{{#legs}} ( ?sliceKey iodp:leg "{{legnumber}}" . ) {{^is_last}} UNION {{/is_last}} {{/legs}} | |
?sliceKey iodp:site "1226" . | |
?slice qb:sliceStructure <http://data.oceandrilling.org/janus/sliceByvcd_image> . | |
?slice qb:sliceStructure ?sliceKey . | |
) | |
"""); | |
var template2 = mustache.parse(source2); | |
var output2 = template2.renderString({'legs': legSet}); | |
print(output2); | |
} |
this is not an issue.. an old version of the library had this issue, it's been long resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the var source I place a SPARQL command with Mustache templating in it. In source2 the same SPARQL but replacing SPARQL's {}'s with ()'s to show how the template engine is generating different results. It sounds like it should not be seeing the single {'s so I am hoping this demonstrates the issue.