Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator doesn’t use renamed custom template files #141

Open
chasenlehara opened this issue Aug 15, 2016 · 5 comments
Open

Generator doesn’t use renamed custom template files #141

chasenlehara opened this issue Aug 15, 2016 · 5 comments

Comments

@chasenlehara
Copy link
Member

Steps to reproduce in a DoneJS app:

  1. Copy the contents of this folder to .donejs/templates/component/modlet/
  2. Rename component.html to demo.html in that folder.
  3. Run donejs add component test

Expected results: src/test/demo.html would exist

Actual results: src/test/test.html exists and is empty.

@matthewp
Copy link
Contributor

Problem is that we have the modlet files hardcoded and just copy those over:

this.modletFiles.forEach(function (name) {

@matthewp
Copy link
Contributor

On second thought, this is working the only way it can. Each of the files in templates/ is a template, it has to be given data before the .html or .js or whatever file can be created. Because of that, it's indelibly tied to the component.js generator. component.js has to know about the templates it uses, it doesn't know that your demo.html is the same as the component.html file it knows about.

I think what you want is a custom generator.

@phillipskevin
Copy link
Contributor

@matthewp since options is passed as the context when copying every template, does the generator really need to know the list of template files?

I think it would be really helpful if we could move the list of files for each generator to within the templates folder for that generator - for example modlet/templates.json. That way we can support things like @chasenlehara is trying to do. Another use case is donejs add sass changing all the component .less files to .scss files.

@matthewp
Copy link
Contributor

I look up table sort of thing might work but I think it's not going to be as flexible as you'll want it to be. It only works if the files map one-to-one, so in the case of .less to .css it works, but if you add some new arbitrary file, the component generator isn't going to know what data to pass into that template.

Think about how you use stache templates, your JavaScript passes data into that template because it knows what data the template needs. It's sort of an interface; as long as you have another template with the same exact interface it works. I just question if it's going to be flexible enough, you might as well write an alternative generator at that point.

@phillipskevin
Copy link
Contributor

The solution we came up with when discussing #148 (comment) was to write out all of the templates in the appropriate .donejs/templates/ folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants