mozilla / nunjucks

A powerful templating engine with inheritance, asynchronous control, and more (jinja2 inspired)

Home Page:https://mozilla.github.io/nunjucks/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: Create nested folder from variable ?

cmoulliard opened this issue · comments

Question

Can nunjucks create a directory structure as proposed hereafter if the variable passed include "/" ?

What we have within the skeleton of the templates project

ls -la qshift/templates/quarkus-extensions/skeletons/src/main/java 
total 0
drwxr-xr-x@ 4 cmoullia  staff  128 Feb  1 16:08 ${{values.java_package_name}}

What we declare => java_package_name=io/quarkus

Expected result

src/
  main/
    java/
      io/
       quarkus/
          Myfile.java

What we got

src/
  main/
    java/
      io/quarkus/
          Myfile.java

Nunjucks itself doesn't create files or directories at all, there's something else going on here and a lot of context missing from the question. It's not clear to me what's going on and I'm not sure how it's relevant to nunjucks.

Your are right. That works doing that using backstage template - https://backstage.io/docs/features/software-templates/writing-templates/#the-templating-syntax

 id: hibernate-orm-rest-dataTemplate
      name: Generating REst...
      if: ${{ 'io.quarkus:quarkus-hibernate-orm-rest-data-panache' in parameters.extensions }}
      action: fetch:template
      input:
        url: skeletons/
        values:
          java_package_name: ${{ parameters.java_package_name }}
          java_package_path: ${{ parameters.java_package_name | replace(".", "/") }}