Nuclear Powered Marshmallows

    qtools-template-replace-for-files

    1.0.0 • Public • Published

    qtools-template-replace-for-files

    Receives a directory containing templates, a replacement object and an output directory path. Applies qtTemplate replace to the contents of the templates.

    Usage:

    Maybe you have this file:

    server {
    	listen 80 ;
    	server_name <!listeningDomain!>;
    
    	location ~ / {
    		proxy_pass <!scheme!>://<!domain!>:<!port!>;
    	}
    }
    

    In a file whose path is /path/to/templateDir/nginxSite.conf.template

    Call like this:

    const resultFilePathList = require('qtools-template-replace-for-files')({
    		templateDirectoryPath:’/path/to/templateDir’,
    		replacementObject:{
    			listeningDomain:’somedomain.com’,
    			domain: '127.0.0.1',
    			scheme: 'http',
    			port:’s7000’
    		},
    		outputDirectoryPath: ‘/path/to/resultDir’
    		)
    	});
    

    It would produce a file containing:

    server {
    	listen 80 ;
    	server_name somedomain.com;
    
    	location ~ / {
    		proxy_pass http://127.0.0.1:7000;
    	}
    }
    

    Named /path/to/resultDir/nginxSite.conf

    Note that ‘.template’ is removed. It is optional but might be helpful to tell which files are templates.

    Also, if there are other file in the source directory, each will be processed and written into resultDir.

    Install

    npm i qtools-template-replace-for-files

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    4.28 kB

    Total Files

    4

    Last publish

    Collaborators

    • tqwhite