Skip to content

Commit

Permalink
📚 Update to using extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ayan-b committed Mar 1, 2019
1 parent f84154f commit 0ff667c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/level-12-use-template-engine-extensions/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,29 @@ Now, let us try to use the extension `with`. To do that, we have to enable the
extension in the `.moban.yml` file following the above syntax. Now, the
extension can be used in the jinja2 templates. One such example is shown in the
`b.template` file.

.. note:
For some extensions, you may need to define `template environment parameters`.
In that case, you can take help of our `user defined template types` feature.
Please read level-18 for more info. We have explained it using an example
here.
Let us consider the example of `jinja2_time`. If you want to use
`datetime_format` attribute, you need to specify the same using environmental
parameters, *i.e* `env.datetime_format = '%a, %d %b %Y %H:%M:%S'`. In order
to do this, you can specify `datetime_format` using environmental parameters,
something like::
configuration:
template_types:
my_own_type:
base_type: jinja2
file_extensions:
- file_type_of_my_choice
options:
datetime_format: %a, %d %b %Y %H:%M:%S
extensions:
- jinja2_time.TimeExtension
targets:
- a.output: a.template.file_type_of_my_choice

0 comments on commit 0ff667c

Please sign in to comment.