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

loading and rendering partials from template? #7

Open
JohnRSim opened this issue Jan 17, 2013 · 5 comments
Open

loading and rendering partials from template? #7

JohnRSim opened this issue Jan 17, 2013 · 5 comments

Comments

@JohnRSim
Copy link

How do you get requirejs hogan plugin to dynamically request load the partials?

Here is a quick example what I mean which doesn't seem to load in picsList

define('picsTpl',['hgn!templates/pics'], function(picsTpl) {
    'use strict';

    return {
        init:{
                var dTpl = picsTpl({
                    items:[{item:{'test123'}}]
                });

                console.log(dTpl);
        }
    }
});

pics.mustache

<ul>
{{#items}}
    {{> picsList}}
{{/items}}
</ul>

picsList.mustache

<li>{{item}}</li>

Thanks

@millermedeiros
Copy link
Owner

I didn't add support for automatic partial load, you need to pass it as second argument to the template method.

picsTpl(data, { picsList : picsListTemplate });

It's definitely doable but not implemented on this plugin, would need some sort of convention (how partials should be looked up?). The handlebars plugin supports this feature.

Will keep this issue open as a feature request but not sure when I will have time to implement it. Thanks.

@JohnRSim
Copy link
Author

Thanks :)
I'll use this its fine.

picsTpl(data, { picsList : picsListTemplate });

@JohnRSim
Copy link
Author

Sorry millermedeiros; I get an error line 71

Uncaught TypeError: Object function (){
            return fn.apply(context, arguments);
        } has no method 'ri' 

and only picsTpl is generated

var dTpl = picsTpl(data,{
    picsList: picsListTpl
});

if I do this it generates the partial but without the data

var dTpl = picsTpl(data,{
    picsList: picsListTpl()
});

if I merge the partial back the template generates fine..

@millermedeiros
Copy link
Owner

ahhh, of course! the partial is a function! I forgot about it... try this:

picsTpl(data, { picsList : picsListTemplate.template });

@JohnRSim
Copy link
Author

Thanks that worked 👍

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

No branches or pull requests

2 participants