Uploaded image for project: 'Apache Freemarker'
  1. Apache Freemarker
  2. FREEMARKER-142

[freemarker-cli] Support Transformation Of Directories

    XMLWordPrintableJSON

Details

    • Task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • None

    Description

      Overview

      Currently ony a single FreeMarker Template can be transformed with a single command line invocation - I suggest to add the following functionality

      • Transform an input directory recursively into an output directory
      • If a template ends with ".ftl" the extension will be removed after processing
      • Only a single directory is support
      • Currently no inclusion / exclusion pattern for templates are supported

      Examples

      Transform Template Directory To STDOUT

      appassembler> ./bin/freemarker-cli -t site/template/
      # == application.properties ==================================================
      server.name=localhost
      server.logs=/var/log/nginx
      # == nginx-conf =============================================================
      server {
        listen 80;
        server_name 127.0.0.1;
      
        root /usr/share/nginx/www;
        index index.htm;
      }
      

      Transform Template Directory To Directory

      appassembler> ./bin/freemarker-cli -t site/template/ -o out; ls -l out
      total 8
      -rw-r--r--  1 sgoeschl  staff  128 May 30 20:02 application.properties
      drwxr-xr-x  3 sgoeschl  staff   96 May 30 20:02 nginx
      

      Pass Parameter On The Command Line

      appassembler> ./bin/freemarker-cli -t site/template/ -P NGINX_HOSTNAME=localhost
      # == application.properties ==================================================
      server.name=localhost
      server.logs=/var/log/nginx
      # == nginx-conf =============================================================
      server {
        listen 80;
        server_name localhost;
      
        root /usr/share/nginx/www;
        index index.htm;
      }
      

      Use Environment Variables

      appassembler> export NGINX_PORT=8080
      appassembler> ./bin/freemarker-cli -t site/template/ -m env:///
      # == application.properties ==================================================
      server.name=localhost
      server.logs=/var/log/nginx
      # == nginx-conf =============================================================
      server {
        listen 8080;
        server_name 127.0.0.1;
      
        root /usr/share/nginx/www;
        index index.htm;
      }
      

      Use Environment File

      appassembler> echo "NGINX_PORT=8080" > nginx.env
      appassembler> ./bin/freemarker-cli -t site/template/ -m nginx.env 
      # == application.properties ==================================================
      server.name=localhost
      server.logs=/var/log/nginx
      # == nginx-conf =============================================================
      server {
        listen 8080;
        server_name 127.0.0.1;
      
        root /usr/share/nginx/www;
        index index.htm;
      }
      

      Use JSON File

      appassembler> echo '{"NGINX_PORT":"8443","NGINX_HOSTNAME":"localhost"}' > nginx.json
      appassembler> ./bin/freemarker-cli -t site/template/ -m nginx.json 
      # == application.properties ==================================================
      server.name=localhost
      server.logs=/var/log/nginx
      # == nginx-conf =============================================================
      server {
        listen 8443;
        server_name localhost;
      
        root /usr/share/nginx/www;
        index index.htm;
      }
      

      Use Environment Variable With JSON Payload

      appassembler> export NGINX_CONF='{"NGINX_PORT":"8443","NGINX_HOSTNAME":"localhost"}'
      appassembler> echo $NGINX_CONF
      {"NGINX_PORT":"8443","NGINX_HOSTNAME":"localhost"}
      appassembler> ./bin/freemarker-cli -t site/template/ -m env:///NGINX_CONF#mimetype=application/json
      # == application.properties ==================================================
      server.name=localhost
      server.logs=/var/log/nginx
      # == nginx-conf =============================================================
      server {
        listen 8443;
        server_name localhost;
      
        root /usr/share/nginx/www;
        index index.htm;
      }
      

      Attachments

        Issue Links

          Activity

            People

              sgoeschl Siegfried Goeschl
              sgoeschl Siegfried Goeschl
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: