expose handlebar instance or add more modifiers

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

expose handlebar instance or add more modifiers

geemang
I'm using the HandlebarsModule mainly for its server side include functionality.   E.g. CSS, javascript includes etc.

My plan is to use angularJS to do the rest. The problem I have is the angularjs and handlebars use the same delimiters. e.g. {{ }}

So, the stuff I want to make it through to angularjs gets processed out of the .hbs files via handlebars.java

If I can get to the handlebars instance I can use setStartDelimiter and setEndDelimiter appropriately.

Can the you either expose the handlebars instance or better yet add a couple modifiers somewhere??  
Reply | Threaded
Open this post in threaded view
|

Re: expose handlebar instance or add more modifiers

Marcin Erdmann
The way to go here would be to create a module binding an eager singleton (https://code.google.com/p/google-guice/wiki/Scopes#Eager_Singletons) that depends on Handlebars and do all the configuration in there and register it after registering HandlebarsModule. This is from the top of my head so might not work as is (in groovy):

class HandlebarsConfigurer {

    @Inject
    HandlebarsConfigurer(Handlebars handlebars) {
        //handlebars instance can be configured in here
    }
}

class HandlebarsConfiguringModule extends AbstractModule {

    @Override
    protected void configure() {
        bind(HandlebarsConfigurer).asEagerSingleton()
     }
}

ratpack {
    modules {
        register new HandlebarsModule()
        register new HandlebarsConfiguringModule()
    }

    ....
}



On Wed, Sep 18, 2013 at 3:27 AM, geemang [via Ratpack Forum] <[hidden email]> wrote:
I'm using the HandlebarsModule mainly for its server side include functionality.   E.g. CSS, javascript includes etc.

My plan is to use angularJS to do the rest. The problem I have is the angularjs and handlebars use the same delimiters. e.g. {{ }}

So, the stuff I want to make it through to angularjs gets processed out of the .hbs files via handlebars.java

If I can get to the handlebars instance I can use setStartDelimiter and setEndDelimiter appropriately.

Can the you either expose the handlebars instance or better yet add a couple modifiers somewhere??  


If you reply to this email, your message will be added to the discussion below:
http://forum.ratpack-framework.org/expose-handlebar-instance-or-add-more-modifiers-tp163.html
To start a new topic under Ratpack Forum, email [hidden email]
To unsubscribe from Ratpack Forum, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: expose handlebar instance or add more modifiers

geemang
Glad someone knows guice :)

That worked. Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: expose handlebar instance or add more modifiers

Marcin Erdmann
Not really, had to look it all up, and I only knew of eager singletons thanks to Luke. :)

Glad it worked! Nice to know that someone is using code that I contributed.


On Wed, Sep 18, 2013 at 1:24 PM, geemang [via Ratpack Forum] <[hidden email]> wrote:
Glad someone knows guice :)

That worked. Thanks!


If you reply to this email, your message will be added to the discussion below:
http://forum.ratpack-framework.org/expose-handlebar-instance-or-add-more-modifiers-tp163p165.html
To start a new topic under Ratpack Forum, email [hidden email]
To unsubscribe from Ratpack Forum, click here.
NAML