Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
This repository was archived by the owner on May 12, 2021. It is now read-only.

Convert builder to template as first parameter format #15

@twolfson

Description

@twolfson

_PAST THOUGHTS_ but still good -- sorry for the ejs =(

We should start specifying template as first parameter to Builder (making it more model/controller like)

define(['Builder','mvc!v/main'], function (Builder) {
  return Builder('main');
});

This allows for proper partials within a view

<div>
<%=Builder('listItem', data);%>
</div>

However, we should have a method to account for dependencies of views, and so...

['mvc!v/listItem'], ['mvc!v/listItem2']
---------------------------
<div>
<%=Builder('listItem', data);%>
<%=Builder('listItem2', data);%>
</div>

should suffice. When the view is defined, we will do a

define(['mvc!v/listItem'], ['mvc!v/listItem2']), function () {
  return myText;
});

The dashes can be of any length but we require one. Alternatively, we can consider HTML comments as the first line but it is getting onto a slippery slope.

Last notes:

  • If a template does not exist, console.error a notification and return an empty jQuery collection
  • Add a method to Builder which takes a template string and renders it directly. (e.g. Builder.render and rename the current Builder.render to Builder.template if it does what I think it does)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions