Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of "jade blocks" in handlebars

Does handlebars have equivalent functionality to jade blocks? I understand that it has partials but I don't see how I can imitate jade's block functionality with just partials.

Here's an example of what I'm trying to accomplish with jade:
Master template:

// layout.jade
doctype 5
html
head
  title= title
  link(rel='stylesheet', href='/stylesheets/style.css')
  block head

body
  header
    block header

  block content

  footer
    block footer

  block scripts

Other template:

// camera.jade
extends layout

block head
  link(rel='stylesheet', href='/stylesheets/camera.css')

block header
  h1 Camera

block content
  section#secScreen
    video#vdoScreen
    aside#asdControls
      nav
        a(href='/') Back
        a(href='') Refresh
        a(href='/gallery') Gallery

block scripts
  script(src='/javascripts/camera.js')

I found this module called handlebars-layouts by shannonmoeller that seems to add this feature, to handlebars. This seems like an alright module but I'd like to know if there's another way to accomplish what I'm trying to do without installing another dependency?

like image 751
17xande Avatar asked Oct 11 '13 12:10

17xande


1 Answers

Not currently, which is why I made handlebars-layouts. If you don't like managing multiple plugins, there's a derivative layouts helper in the excellent handlebars-helpers collection with over a hundred other helpers.

like image 181
Shannon Moeller Avatar answered Oct 12 '22 09:10

Shannon Moeller