Giter Club home page Giter Club logo

Comments (10)

codeBelt avatar codeBelt commented on June 6, 2024 2

@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.

codeBelt avatar codeBelt commented on June 6, 2024

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.

edhine avatar edhine commented on June 6, 2024

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.

codeBelt avatar codeBelt commented on June 6, 2024

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.

edhine avatar edhine commented on June 6, 2024

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.

codeBelt avatar codeBelt commented on June 6, 2024

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.

edhine avatar edhine commented on June 6, 2024

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.

edhine avatar edhine commented on June 6, 2024

It is exactly what I mentioned !!!

from generate-template-files.

codeBelt avatar codeBelt commented on June 6, 2024

Ok, I will try to get a new build out tomorrow.

from generate-template-files.

codeBelt avatar codeBelt commented on June 6, 2024

@edhine This feature is now in version 2.1.0

from generate-template-files.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.