-
Notifications
You must be signed in to change notification settings - Fork 28
Migrating from jade to blade
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 is stricter in blade. Don't indent unless you really have to! And only indent one level.
- for x in list
becomes
foreach list as x
include a/b/c
becomes
include "a/b/c"
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
mixin myMixin(a,b,c)
...
becomes
function myMixin(a,b,c)
...
mixin myMixin(a,b,c)
becomes
call myMixin(a,b,c)
script.
...
becomes
:javascript
...
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.