Skip to content

Instantly share code, notes, and snippets.

@fils
Created April 10, 2013 20:49
Show Gist options
  • Save fils/5358320 to your computer and use it in GitHub Desktop.
Save fils/5358320 to your computer and use it in GitHub Desktop.
Demonstration of an issue I am seeing with Dart Mustache templating
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);
}
@fils
Copy link
Author

fils commented Apr 10, 2013

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