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

Define template dependencies for inline partials (amd) #74

Closed
shioyama opened this issue Nov 1, 2012 · 5 comments
Closed

Define template dependencies for inline partials (amd) #74

shioyama opened this issue Nov 1, 2012 · 5 comments

Comments

@shioyama
Copy link

shioyama commented Nov 1, 2012

Haml coffee assets is wonderful, I use it heavily and was happy to see the recent commit (e3287d3) and template adding support for amd/require.js. I've followed the steps and everything works fine, but when migrating my existing templates I stumbled on the issue of how to include inline partials, described in a stackoverflow answer using JST.

So normally, this is how you would include one template (test) in another one:

%p Another template
!= JST['test']()
%p That includes a partial

What I have done to make this work with amd is to switch the JST for a require call:

%p Another template
!= require('assets/templates/test')()
%p That includes a partial

This works as long as I make sure to include 'assets/templates/test' as a dependency in whatever code I'm calling the template from. Ideally though (in keeping with the philosophy of amd) I'd like to define the dependency directly in the template itself, so I don't have to include it wherever the template is called from.

Is this possible? I see that in the generated javascript there is a define function around the template code with no dependency array. That's where I'd like to add the dependencies, if possible.

Thanks in advance!

@netzpirat
Copy link
Collaborator

Oh yeah, I saw this issue coming :D This is currently not possible, but I'll add support for it in haml-coffee asap. Stay tuned!

@shioyama
Copy link
Author

shioyama commented Nov 1, 2012

That would be great, thanks! Look forward to it.

@netzpirat
Copy link
Collaborator

Trivial AMD dependency management is done netzpirat/haml-coffee@f614940 The Haml Coffee Assets integration comes as next...

@shioyama
Copy link
Author

shioyama commented Nov 2, 2012

Wow thanks so much!

@shioyama
Copy link
Author

shioyama commented Nov 2, 2012

Amazing, will try this out very soon. Thanks so much for getting this up and running so fast.

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

No branches or pull requests

2 participants