Template paths use JavaScript syntax with a few small modifications.

ANCHORModel values

What would be identifiers for variable names in JavaScript get a value from the model and bind to any updates. If the path returns null or undefined, nothing is rendered.

Examples of rendering model values:





var userId = model.get('userId');
model.get('users.' + userId);


Values are passed into views with attributes. Within the view, these values are accessed via paths that start with an at sign (@). In addition, there is an @content attribute created for any content inside of a view tag.

  <ul class="nav-links">
    <view is="nav-link" href="/">Home</view>
    <view is="nav-link" href="/about">About us</view>

    {{if $render.url === @href}}
      <a href="{{@href}}">{{@content}}</a>

See View attributes for additional detail on passing data to views.


Aliases label path expressions. They must begin with a hash (#) character to make it more obvious whether a path is an alias or a model value. Each of the block types support defining aliases with the as keyword.

Aliases make it possible to refer to the scope of the current block or a parent block.

{{with user as #user}}
  {{if #user.friendList as #friendList}}
    <!-- Note that we can refer to the parent scope -->
    <h3>Friends of {{}}</h3>
      {{each #friendList as #friend}}


Relative view paths begin with this. They refer to the expression in the containing block.

Aliases are preferred to relative paths, as they are more clear. Relative paths came from implementing a syntax inspired by Handlebars, but Derby has been moving toward increased consistency with JavaScript, and the alternate use of the keyword this is confusing. Expect that this feature will be removed in a future version of Derby.

{{with user}}
  {{if this.friendList}}
      {{each this}}
Edit on GitHub