Comments (3)
I have another project jinjyaml, it provides pyYAML parser and loader for Jinja2 template express/object
But i haven't tried to use them together.
from pyyaml-include.
Thanks, I'll keep an eye on your new project.
To make this more clear. I was using the pyyaml-include first, then the jinja2 render last. I found out the yaml dump from the pyyaml include module was changing the quotes to where the jinja2 enginer render couldn't process it.
Instead, I force the jinja2 render first, for all templates that will be used by pyyaml include, then run that include module last. It works as expected now.
Thanks
from pyyaml-include.
The project is based on pyYAML
Constructor
, which is a part of it's YAML parser.
When including another YAML file, it (the file) will be parsed into YAML objects(Scalar, Sequence, or Mapping object), then put to the place where the "!include" tag is.
So, the Jinja2 template expressions won't be recognized during the including process.
for example, a file like:
{% for employee in department.employees %}
- name: employee.name
age: employee.age
{% endfor %}
can not be included, cause it's legal for Jinja, but illegal for YAML. Unless we render it before including.
For a "render after include" usage, i think jinjyaml is helpful.
It provides Jinja2 template constructor/tag.
We can rewrite Jinja2 template in above example to a YAML with a special tag:
!jinja2 |
{% for employee in department.employees %}
- name: employee.name
age .employee.age
{% endfor %}
Such a fragment will be parsed to a jinjyaml.JinjyamlObject
object (note that we shall add jinjyaml constructor to FullLoader first). Thus we can render it later.
from pyyaml-include.
Related Issues (20)
- readers_map not getting picked up: RuntimeError: Un-supported file name HOT 5
- Python 3.6 unsupported after releasing `1.2.post1` HOT 2
- Publish sdist to PyPI HOT 2
- two files in one dict? HOT 8
- Include and achors HOT 3
- include specific components from other yamls? HOT 2
- Does not support top level include with other keys HOT 2
- Relative include: relativeto the current file? HOT 8
- Could you update the PyPI to new version to add PyYAML 6.0 support? HOT 2
- How to concatenate two yaml files? HOT 1
- Ability for default value HOT 1
- Wildcard with Hash/Dict/Map HOT 1
- Idea: include from remote storages (notably git) HOT 3
- Yaml anchor support for include yaml files HOT 1
- Use tag with anchors across a single yaml config file HOT 2
- It seems that I can't rewrite the inherited argments from base `yaml` file. HOT 5
- Python 3.10 unsopported? HOT 2
- yaml writer? HOT 1
- How to make the package work with setuptools lower than 61.0.0 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyyaml-include.