-
Notifications
You must be signed in to change notification settings - Fork 1
Built in Functions (fns)
Robertus Johansyah edited this page Jun 8, 2018
·
2 revisions
p = Parse(names={'test': 1})
p.load('file.yml') # file.yml
test_1: 1
test_2:
# example1: template as string, notice I dont add extra variables, it is seamless names from input (test) and template (test_1)
F.template: "{{ R.test_1 + test }}"
test_3:
# example2: it can load file (borrowing F.inc capabilities), if template_file.txt is {{1 + 2}}
F.template: F.inc("template_file.txt")
test_4:
# example3: this where attaching more complex object (including ur usecase of looping)
test_4_0: [3, 4]
F.template: |
test_4_1: {{ R.test_1 }}
test_4_2: {{ 1 + 1 }}
{% for i in R.test_4.test_4_0 %}
test_4_{{ i }}: i
{% endfor %} # result
{
test_1: 1,
test_2: 2,
test_3: 3,
test_4: {
test_4_0: [3, 4],
test_4_1: 1,
test_4_2: 2,
test_4_3: 3,
test_4_4: 4
}
}