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

Example of how to extend the global context? #2

Open
huetsch opened this issue Mar 19, 2014 · 1 comment
Open

Example of how to extend the global context? #2

huetsch opened this issue Mar 19, 2014 · 1 comment

Comments

@huetsch
Copy link

huetsch commented Mar 19, 2014

The haml_coffee_assets wiki and README give a pretty clear example of how to extend the global context by overriding HAML.globals. However, I believe those examples are not really relevant to the case where we're using AMD.

The README also references the global_context_asset for server-side rendering or customizing the context function itself. I'm not interested in server-side rendering at the moment, and it's unclear to me how the script loading order would work in the event of customizing the context function itself.

I've started looking at the code to try to decipher all this, but I haven't managed to dig it out yet and it occurs to me that this is an issue others will likely face as well.

Could you please add a simple example of using the global context when using the AMD version of haml_coffee_assets?

@netzpirat
Copy link
Owner

I'm not familiar with AMD and do not use it myself. Support has been developed on popular request and I never got any feedback afterwards, so I'm not sure how people are using it.

You can have a look at the relevant code in the Haml_Coffee_Assets wrapper for Haml-Coffee here: https://github.com/netzpirat/haml_coffee_assets/blob/master/lib/js/haml_coffee_assets.js#L84-L93 If AMD is enabled and the hc module is present (which is included by default), we simply call the context method on the hc module. You'll find the default module implementation here. I do not have a clue how overwriting this in the asset pipeline and AMD works, but I guess user assets have precedence over gem vendor assets, so you might just want to copy over hamlcoffee_amd and modify it to your needs.

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