bminer / node-blade

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

Blank document crashes application in Meteor #149

Closed g8d3 closed 11 years ago

g8d3 commented 11 years ago

Hi, when I have a blank blade page, I get this:

Your app is crashing. Here's the latest log.

Errors prevented startup:
Exception while bundling application:
SyntaxError: Parser error: Expected blank line, block definition, block modifier (i.e. append, prepend, or replace), block render, c-style block comment, code, comment, constant block, doctype, event handler, filter, foreach else block, foreach list block, function call, function definition, include, isolate, line of text, preserve block or tag but end of input found.
bminer commented 11 years ago

Hmm... never thought about this case before. Yeah... a blank Blade template is invalid according to the Blade parser. Would you like this to be fixed?

Obviously a workaround is to simply include something in the Blade template. Even a //- comment will work, but it won't render as anything.

g8d3 commented 11 years ago

yes, :+1:

g8d3 commented 11 years ago

Another thing, can you help me with this?, I am starting an application with Meteor, and:

include 'shared/map'         # this does not work
!= Template 'shared/map'     # this does

I have map.blade file in my_app/client/views/shared/ directory.

bminer commented 11 years ago

what version of blade are you running? A recent update might have fixed your issue.

g8d3 commented 11 years ago

I have v3.0.0rc5 in smart.lock file.

bminer commented 11 years ago

@juanpastas - Could you post the contents of map.blade along with the full stack trace of the Error message you are getting? Also, Blade 3.0.0rc6 will correct the "Blank document" issue.

g8d3 commented 11 years ago

It just has a placeholder:

script src='https://maps.googleapis.com/maps/api/js?sensor=false'
.map the map

Also I would like the script tag to be included correctly, I think I am going to do this with a javascript helper, unless you have another suggestion, for example using blocks, I actually did not understand why blocks are not recommended with Meteor.

bminer commented 11 years ago

A few things...

1.) Your code in map.blade should probably read:

script(src='https://maps.googleapis.com/maps/api/js?sensor=false')
.map the map

2.) Could you post the full stack trace of your error message? 3.) Blocks are not recommended in Meteor for a few reasons. Check this out: https://github.com/bminer/node-blade/wiki/Using-Blade-with-Meteor#wiki-block_limitations

g8d3 commented 11 years ago

1) actually I would want script to be included in head, how could I do that? 2) I am not having errors, what I am trying to do is 1) 3) that's difficult to understand for me, because I don't know which are the ways to work with templates in Meteor, I always see a template inside another template,

  1. even in startup body is populated with a template with Handlebars
  2. I am doing this to start showing my first template with Blade:
#Meteor.startup ->
$ ->
  a = ->
    $('body').html( Template['meals/index']() )
  setTimeout a, 100 # just because a weird error spawning from jQuery mobile
  #a= -> $('body').html( Template.mobile() )
  #setTimeout a,100

meals/index

p index
!= Template['shared/map']()

shared/map

script(src='https://maps.googleapis.com/maps/api/js?sensor=false')
.map the map

Do you have a sample application for blade?

bminer commented 11 years ago

1.) Put it in head.blade 2.) See above 3.) Agreed. Having a template within another template is basically using the include statement. Blocks, in these cases, aren't necessary. 4.) Blade was just changed (in 3.0.0 stable) to support dynamic body.blade templates. The contents of this template are rendered just after the initial page load. See https://github.com/bminer/node-blade/wiki/Using-Blade-with-Meteor for more details. 5.) The whole setTimeout call should not be necessary if you are using Meteor.startup, correct? Otherwise, your templates look fine. Just make sure that you put your <script> tag in head.blade.

Hope that helps. Please feel free to email me or open another issue, if necessary. My contract info is here: http://blakeminer.com/contact.php