qtools-template-replace-for-files
v1.0.0
Published
Receives a directory containing templates, a replacement object and an output directory path. Applies qtTemplate replace to the contents of the templates.
Downloads
1
Maintainers
Readme
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.