github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0069.yml (about)

     1  doc_meta: |
     2    folder: templating
     3    title: templating using dvar
     4    head: |
     5      Showcase how to use external tool, eg shell script to tempate content
     6  
     7    sections:
     8      - title: template dynamic content
     9        content: |
    10          Note that the content of school_address is templated from defined global runtime var
    11  
    12          ```
    13          address:
    14            suburb:
    15              name: {{.student.address.suburb.name}}
    16              postcode: 2000
    17              CBD: yes
    18            school: {{.student.address.school}}
    19  
    20          ```
    21  
    22          The rendered content is dumped to a file and shown afterwards
    23  
    24      - title: Demo
    25        log: yes
    26  
    27  notes:
    28    goal:
    29      - demo how to template a file
    30  
    31  vars:
    32    student:
    33      name: Tom
    34      gender: Male
    35      address:
    36        suburb:
    37          name: sydney
    38          postcode: 2000
    39          CBD: yes
    40        school: Sydney Grammar
    41  
    42  dvars:
    43  
    44    - name: school_address
    45      ref: d0069.yml
    46  
    47  tasks:
    48  
    49    - name: task
    50      task:
    51        -
    52          func: shell
    53          do:
    54            - echo """school address {{.school_address}}"""
    55            - echo """school address {{.school_address}}""" > /tmp/school.txt
    56            - cat /tmp/school.txt