bminer / node-blade

Blade - HTML Template Compiler, inspired by Jade & Haml
Other
320 stars 28 forks source link

Meteor/Blade not rendering #98

Closed PastorBones closed 12 years ago

PastorBones commented 12 years ago

I've got blade working with Meteor and it's rendering static html fine. However, I'm getting a bundle error when trying to use template variables.

Client.js

    Template.info.player = function(){
        var data = Session.get( 'data' );
        return data.player;
    };

info.blade

.player-name.large= player.name
.alliance-name= alliance.name
.world-name= world.name

Error

Errors prevented startup:
Exception while bundling application:
ReferenceError: player is not defined
    at /home/pastorbones/meteor/loutell/views/info.blade:1:1

1 > .player-name.large= player.name
bminer commented 12 years ago

Good point. Helpers don't work yet in Blade. Thanks for pointing out this issue. This will be addressed shortly.

bminer commented 12 years ago

Actually... on second thought... why would that show up as a bundle error? Is your info.blade template included in your body.blade template? Do you even have a body.blade template? If so, could you post it here?

PastorBones commented 12 years ago

Here's pretty much everything besides the Meteor.method that gathers data from the server (through an additional api call of a external MMO). The Session variables are being set properly within that method call...

client.js

{project}/client/client.js

if( Meteor.is_client) {
    // Session('data') is being set in a Module.call

    Template.info.alliance = function(){
        var data = Session.get( 'data' );
        return data.alliance;
    };
    Template.info.player = function(){
        var data = Session.get( 'data' );
        return data.player;
    };
}

Templates

{project}/views/body.blade

body
    .navbar.navbar-inverse.navbar-fixed-top
        .navbar-inner
            .container-fluid
                .brand MySite
    .container-fluid
        .row-fluid
            .span3
                include 'sidebar'

{project}/views/sidebar.blade

#sidebar.well.sidebar-nav
    include 'info'

{project}/views/info.blade

.player-name.large= player.name
.alliance-name= alliance.name
.world-name= world.name
bminer commented 12 years ago

EDIT: Ignore this comment. As of Blade 3.0.0 stable, you can use helpers in body.blade templates.

Helpers do not work in body.blade templates. If your body.blade file includes another file that uses helpers, it will also not work.

This is by design. body.blade files are for rendering initial static page content only. Handlebars uses another approach, which allows for dynamic content; however, I believe that it's a bit confusing, since Handlebars does not allow for dynamic content in <head> tags.

Thoughts on this?

See this wiki page for more information.

VanCoding commented 12 years ago

I've asked the following question previously on SO: http://stackoverflow.com/questions/13438793/meteor-blade-included-templates-still-use-the-context-of-the-parent

Could it be that it is related to this?

bminer commented 12 years ago

@VanCoding - probably not. The link you posted above is a separate bug. :-/