Skip to content

Template variables for target and template #29

@jayvdb

Description

@jayvdb

Sometimes it is useful to know the target name, and possibly also the (top level) template name being processed.

e.g. Shippable CI supports running from a .travis.yml, as mentioned at http://docsv2.readthedocs.io/en/latest/config.html#shippable-yml , however there are some perticular differences, like python: 3.4.4 doesnt work because Shippable expects only x.y. (coala uses 3.4.4 )

While it is currently possible to handle this minor difference by creating shippable.yml.jj2 which overrides blocks of travis.yml.jj2 , if the difference is removing only .4 it would be nice to include this inside travis.yml.jj2

{% if __target__ != 'shippable.yml' %}.4{% endif %}

and then the template is invoked twice at

targets:
  - .travis.yml: travis.yml.jj2
  - shippable.yml: travis.yaml.jj2

The same thing can be achieve slightly better if the top level template name is also exposed, which creates a more logical form of polymorphism.

symlink shippable.yml.jj2 -> travis.yaml.jj2

then inside travis.yml.jj2,

{% if __template__ != 'shippable.yml.jj2' %}.4{% endif %}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions