generator-backbone icon indicating copy to clipboard operation
generator-backbone copied to clipboard

Compilation broken in subdirectories (coffee, jst, handlebars, ...)

Open adammunoz opened this issue 12 years ago • 8 comments

Hi there,

I noticed quite an annoying misconfiguration in Gruntfile.js.

At least in the following tasks:

  • jst
  • handlebars
  • coffee
  • sass (although not fully tested)
  • test (although this one is warned on the file top comments as being for performance reasons)

We are only specifying one level in the files configuration: *.hbs, *.coffee where it should be either **/*.hbs or {,*/}*.hbs (the same goes for the other file types, coffee, etc ...)

I think the current behaviour is quite confusing for new users who will for example put their models in scripts/models/ only to find that they are not compiled. They might as well think that the generator is broken without even trying to find why it is not compiling.

Yeoman/webapp generator has it right, I think backbone generator should follow the same philosophy instead of asking users to dig into the gruntfile to see why their files are not being compiled

adammunoz avatar Jun 25 '13 07:06 adammunoz

In fact adding to the above: **/*.ext is better since {,*/}*.ext only goes one further level down and we are with the same problem if the user has 2 nested subdirectories

adammunoz avatar Jun 25 '13 07:06 adammunoz

Regarding the coffee and sass task this is already fixed in master.

Regarding the templates this is okey for the default behaviour since yeoman creates all the templates in the templates folder not in subdirectories.

revathskumar avatar Jun 26 '13 16:06 revathskumar

@revathskumar , I think some of of us (maybe many of us?) like to organize our templates following a logic folder structure rather than have them all mixed up in the same level. Something like the following is quite common in my workflow: templates/a_component/a_sub_subcomponent/.../the_template.hbs

At least I think it might be worthwhile to warn users about the default behaviour being that templates are going to be compiled only if they are on the first level of the templates directory, and possibly document how to change that in the Gruntfile.js in case they want to have a more complex folder structure to store their templates

adammunoz avatar Jun 27 '13 00:06 adammunoz

When it comes down to patterns for directory organization, I favor us opting for the simplest common-denominator and documenting ways to customize this as there will almost certainly be people that want to change it.

As the first of your earlier points was addressed already, I recommend we do:

At least I think it might be worthwhile to warn users about the default behaviour being that templates are going to be compiled only if they are on the first level of the templates directory, and possibly document how to change that in the Gruntfile.js in case they want to have a more complex folder structure to store their templates

addyosmani avatar Jul 05 '13 09:07 addyosmani

+1 for adding support for sub directories.

mihow avatar Jul 07 '13 19:07 mihow

At least I think it might be worthwhile to warn users about the default behaviour being that templates are going to be compiled only if they are on the first level of the templates directory, and possibly document how to change that in the Gruntfile.js in case they want to have a more complex folder structure to store their templates

They already are warned in the Gruntfile: https://github.com/yeoman/generator-backbone/blob/master/app/templates/Gruntfile.js#L9-L13

But all the path/*.ext should be changed to path/{,*/}*.ext to be consistent in the project and across generators

eddiemonge avatar Dec 08 '13 18:12 eddiemonge

@eddiemonge i agree.

sindresorhus avatar Dec 11 '13 17:12 sindresorhus

+1 to support nested templates (at least one extra level)

Regarding the templates this is okey for the default behaviour since yeoman creates all the templates in the templates folder not in subdirectories.

@revathskumar Even though backbone generator and yo generate files in top level /templates, there might be other nested files. Why leave this out when the probability of it breaking for users is quite high? (just happened to me and got here :/) Like @eddiemonge mentioned, I think we should make it consistent across generators by going with path/{,*/}*.ext

PS: Any performance benchmarks available?

jaseemabid avatar Dec 28 '13 08:12 jaseemabid