Comments (10)
@edhine check out my changes: https://github.com/codeBelt/generate-template-files/pull/24/files
Pull that branch down and do a yarn && yarn build
. Then cd
in to the examples
folder and do yarn generate
. If you look at the templates/angular/ngrx-store/__name__.reducer.spec.ts
you can see I added
// Version: __version__(noCase)
// Description: __description__(noCase)
Here I am using data from the package.json
file.
const config = require('../package.json');
generateTemplateFiles([
// Angular
{
option: "Angular Ngrx Store",
defaultCase: '(pascalCase)',
entry: {
folderPath: './tools/templates/angular/ngrx-store/',
},
stringReplacers: ['__name__', '__model__'],
dynamicReplacers: [
{slot:'__version__', slotValue: config.version},
{slot:'__description__', slotValue: config.description}
],
output: {
path: './src/app/stores/__name__(lowerCase)',
pathAndFileNameDefaultCase: '(kebabCase)',
},
}
]);
Let me know if this is what you wanted
from generate-template-files.
stringReplacers
only accepts an array of strings. It should be:
stringReplacers: ['__name__', '__model__'],
I see that you are trying to use an object {slot:'__name__', slotValue: 'asdasdada'}
. This is wrong. You will only see that structure in the onComplate callback.
from generate-template-files.
Is there any way to define the variables in any file or other way without having to enter them by console?
from generate-template-files.
Not at the moment but I could add that in. So you want some like this:
const someVarData = 'Dude!';
generateTemplateFiles([
// Angular
{
option: "Angular Ngrx Store",
defaultCase: '(pascalCase)',
entry: {
folderPath: './tools/templates/angular/ngrx-store/',
},
stringReplacers: [{slot:'__name__', slotValue: someVarData}, '__model__'],
output: {
path: './src/app/stores/__name__(lowerCase)',
pathAndFileNameDefaultCase: '(kebabCase)',
},
},
]);
I am going to assume that the only question that will be asked is for __model__
because __name__
will already have a value. Anywhere in your templates __name__
will be replaced with Dude!
. Does that sound correct?
from generate-template-files.
yes, basically the objective is to define them both in a file or directly in the generator, since I want to upload the templates to git and to encode a process that downloads the git template and applies the already defined variables
from generate-template-files.
I think I will create a new property dynamicReplacers
. I will try to work on in the next day or two.
const someVarData = 'Dude!';
generateTemplateFiles([
// Angular
{
option: "Angular Ngrx Store",
defaultCase: '(pascalCase)',
entry: {
folderPath: './tools/templates/angular/ngrx-store/',
},
stringReplacers: ['__model__'],
dynamicReplacers: [{slot:'__name__', slotValue: someVarData}],
output: {
path: './src/app/stores/__name__(lowerCase)',
pathAndFileNameDefaultCase: '(kebabCase)',
},
},
]);
from generate-template-files.
Thank you very much, I know it will help several people, I love how it is done, very good job: D! I'm sorry for the English I use because my native language is Spanish.
from generate-template-files.
It is exactly what I mentioned !!!
from generate-template-files.
Ok, I will try to get a new build out tomorrow.
from generate-template-files.
@edhine This feature is now in version 2.1.0
from generate-template-files.
Related Issues (20)
- Is there a way to pass an input in one single commands? HOT 18
- Description of the string replacers HOT 3
- stringReplacers is not optional HOT 2
- stringReplacers should be mandatory even for command line usage HOT 2
- Non-interactive / Batch Mode HOT 1
- Is there a default slot value to fallback to? HOT 2
- Any ideas/chances to run it with Arrays/Objects properly? HOT 3
- Code editor barking at improper syntax HOT 6
- Prompt confirmation before files are written HOT 1
- How Can I add branch and PR? HOT 1
- Is it possible to use CaseConverter per stringReplacers? HOT 2
- ConfigItem.output.path as string or function HOT 1
- Add `caseConverter__` values to `CaseConverterEnum` HOT 3
- Emitter-mixin deprecation warning HOT 1
- [Question] Is there a way to run a generate without the interactive cli? HOT 1
- [Question] Is there a way to silence console messages? HOT 3
- [Question] Is there a way I can call multiple options at once HOT 1
- The result file generated by the binary template file is damaged
- Having a default replacement string HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from generate-template-files.