aberman / html2js-brunch

A Brunch version of grunt-html2js
MIT License
1 stars 3 forks source link

joinTo should filter out templates based on a regex or callable function #1

Open dziegler opened 10 years ago

dziegler commented 10 years ago

It doesn't seem that the regex/callable in the joinTo clause works properly. E.g.

templates: {
    joinTo: {
        'templates-app.js': /^app/,
        'templates-common.js': /^common/,
        'templates-admin.js': function(path) {
            return /^admin/.test(path);
        }
    }
}

This seems to work as far as filtering out the correct tpl.html files to include, but the top angular.module that gets prepended to the file includes every module, not just the filtered modules.

I'm new to brunch so I don't know if there's a simpler patch, but this seems to work for me.

dziegler commented 10 years ago

Also added an option to specify the module name, since this was causing problems for me.

aberman commented 10 years ago

I originally had the module name option (like grunt-html2js it was called 'module') in the code but removed it because it didn't make sense for Brunch. Can you explain what issues you ran into without it? The problem with your implementation is that your module name will be the same for all three of your concatenated files, which doesn't work.

I'll look at your other patch tomorrow.

dziegler commented 10 years ago

I'm concatenating my app and template javascript into one file, e.g.

templates: {
    joinTo: {
        '/dir/app.js': /^app/
    }
}
templates: {
    joinTo: {
        '/dir/app.js': /^app/
    }
}

If I merge it all into app.js then I have to call my template module 'app'. It works but is kind of weird.

For my use case, the reason I have multiple template js files is because they get served for different apps. They don't get loaded together so it's not a problem that they share the same module name, but I agree it might not be ideal.