Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Migrating from jade to blade

Paul "Joey" Clark edited this page · 2 revisions

Debugging / Errors

Most blade errors will indicate where the error occurred with >. Look for the >!

Occasionally (once you have fixed all the well-described errors) Blade will give a completely uninformative error (something akin to "I failed"). This does not help us to debug. The easiest solution I found was to delete most of the template, then add bits back in until it broke again, hence isolating the issue.

(If Blade gave more useful error messages, we might have switched to it. But it was one of the major reasons we ended up sticking with Jade! Anyway I digress.)

Here's what you need to know when converting your Jade templates into Blade templates... (brought to you by joeytwiddle at Sunride!)

Indentation

Indentation is stricter in blade. Don't indent unless you really have to! And only indent one level.

Loops

- for x in list

becomes

foreach list as x

Includes

include a/b/c

becomes

include "a/b/c"

Extending

extends a/b/c

becomes

include "a/b/c"

and then an extend block

block thisBlock
  ...

becomes

replace thisBlock
  ...

The original template can remain the same

Mixins

Definition

mixin myMixin(a,b,c)
  ...

becomes

function myMixin(a,b,c)
  ...

Calling

mixin myMixin(a,b,c)

becomes

call myMixin(a,b,c)

Javascript blocks

script.
  ...

becomes

:javascript
  ...

Style blocks

style.
  ...

becomes

:stylus
  ...

or

:sass
  ...

but both of those require installing extra libraries.

A simpler way I found was just to write some unescaped HTML:

!
  <style>
  ...
  </style>

There may be a better way, but I haven't found it yet.

Something went wrong with that request. Please try again.