Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Support for handlebar partials #842

Merged
merged 26 commits into from

2 participants

@caridy
Owner

##Example:

./MojitName/views/
    foo.hb.html
./MojitName/views/partials/
    bar.hb.html

by following that structure, you should be able to define foo.hb.html like this:

<div id="{{mojit_view_id}}">
    {{> bar}}
</div>

Few more notes:

  • a partial view can be used by any view within the same context/mojit.
  • global partial views are also supported.

##Details:

  • adding support for partials in the store. there is now instance.partials with a similar structure than instance.views after expanding the instance.
  • views within partials/* folder are now consider partials, which are an special type of view.
  • adding support for application.json->viewEngine->preloadTemplates to preload any view in memory, and this is disabled by default.
  • consolidating application.json->viewEngine->cacheTemplates as a static config across the board.
  • adding support for preloadTemplates for HB client and server to avoid loading the template if is is part of the expanded instance.
  • adding support for partials on hb client and server.
  • view-renderer is now a class and a factory to avoid creating renderer objects over and over again.
  • removing viewId argument that is not really relevant for this abstraction.
  • using the new Y.mojito.ViewRenderer() factory to access the renderer instance.
  • removing unnecesary dependencies (mojito-perf).
  • removing unnecessary configuration that is not semantically correct for action-context or mojito-client like cacheTemplates and pathToRoot.

Second attempt for PR #683

caridy added some commits
@caridy caridy adding support for partials in the store. views within partials/* fol…
…der are now consider partials, which are an special type of view. Adding support for application.json->viewEngine->preloadTemplates to preload any view in memory, and this is disabled by default for now
374826d
@caridy caridy consolidating application.json->viewEngine->cacheTemplates as a stati…
…c config across the board. Adding support for preloadTemplates for HB client and server to avoid loading the template if is is part of the expanded instance. Adding support for partials on hb client and server.
9a40739
@caridy caridy view-renderer is now a class and a factory to avoid creating renderer…
… objects over and over again. removing viewId argument that is not really relevant for this abstraction.
da53ea3
@caridy caridy using the new Y.mojito.ViewRenderer factory to access the renderer in…
…stance. removing unnecesary dependencies and unnecessary configuration that is not semantically correct for action-context or mojito-client
6b2a5c4
@caridy caridy getting pr4 merged for partials 459bd50
@caridy caridy adding warning and moving assets for top level views to exclude them …
…from partials
a2311e4
@caridy caridy Merge branch 'develop-perf' of git://github.com/yahoo/mojito into par…
…tials
82fcda6
@caridy caridy Merge branch 'yui-name-collision' of github.com:caridy/mojito into gl…
…obal-models
baed690
@caridy caridy supporting registration of global models f5251aa
@caridy caridy Merge branch 'develop-perf' of git://github.com/yahoo/mojito into par…
…tials
5948e36
@caridy caridy Merge branch 'develop-perf' of git://github.com/yahoo/mojito into par…
…tials
e6499c5
@caridy caridy Merge branch 'develop-perf' of git://github.com/yahoo/mojito into par…
…tials
9d75095
@caridy caridy merge partials and 0.5.0GA 2044d1f
@caridy caridy Merge branch 'develop' of yahoo/mojito into partials 5721724
@caridy
Owner

This is set to land on 0.5.2.

@caridy
Owner

Ready for review.

@drewfish
Owner

From reading the description:

I worry about getting rid of pathToRoot. It was necessary for some users of mojito build html5app. Evidence strongly suggests that this was no longer being used (dead code) anyways.

@drewfish drewfish commented on the diff
lib/app/addons/view-engines/hb.client.js
((16 lines not shown))
HandleBarsAdapter.prototype = {
/**
* Renders the handlebars template using the data provided.
* @param {object} data The data to render.
- * @param {string} mojitType The name of the mojit type.
- * @param {string} tmpl The name of the template to render.
+ * @param {object} instance The expanded mojit instance.
@drewfish Owner

Passing the whole instance, nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@drewfish drewfish commented on the diff
lib/app/autoload/store.server.js
((5 lines not shown))
- details.views[res.name] = {};
- }
- if (env === 'client') {
- details.views[res.name]['content-path'] = res.url;
+ template = {
+ 'content-path': (env === 'client' ?
+ this._libs.path.join(this._appConfigStatic.pathToRoot || '', res.url) :
+ res.source.fs.fullPath),
+ 'content': res.content,
+ 'engine': res.view.engine
+ };
+ // we want to separate partials from actual templates
+ // in case the engine supports partials
+ if (res.name.indexOf('partials/') === 0) {
+ // removing the "partials/" prefix
+ details.partials[this._libs.path.basename(res.name)] = template;
@drewfish Owner

This looks like it won't support subdirectories in views/partials/, which might be nice to have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@drewfish
Owner

+1 good stuff.

One comment about supporting subdirectories in views/partials/, but we can add that feature in the future when/if requested.

@caridy
Owner

Thanks @drewfish, I will resolve the conflicts and merge.

@caridy caridy merged commit d7c0e8b into yahoo:develop
@isao isao referenced this pull request from a commit in isao/mojito
@isao isao fix unit tests after newsboxes code was updated for pull #842 71e02ac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 30, 2012
  1. @caridy

    adding support for partials in the store. views within partials/* fol…

    caridy authored
    …der are now consider partials, which are an special type of view. Adding support for application.json->viewEngine->preloadTemplates to preload any view in memory, and this is disabled by default for now
  2. @caridy

    consolidating application.json->viewEngine->cacheTemplates as a stati…

    caridy authored
    …c config across the board. Adding support for preloadTemplates for HB client and server to avoid loading the template if is is part of the expanded instance. Adding support for partials on hb client and server.
  3. @caridy

    view-renderer is now a class and a factory to avoid creating renderer…

    caridy authored
    … objects over and over again. removing viewId argument that is not really relevant for this abstraction.
  4. @caridy

    using the new Y.mojito.ViewRenderer factory to access the renderer in…

    caridy authored
    …stance. removing unnecesary dependencies and unnecessary configuration that is not semantically correct for action-context or mojito-client
Commits on Nov 15, 2012
  1. @caridy
  2. @caridy
Commits on Nov 17, 2012
  1. @caridy
  2. @caridy
  3. @caridy
Commits on Nov 19, 2012
  1. @caridy
Commits on Nov 20, 2012
  1. @caridy
Commits on Nov 21, 2012
  1. @caridy
Commits on Dec 6, 2012
  1. @caridy

    merge partials and 0.5.0GA

    caridy authored
  2. @caridy
Commits on Dec 7, 2012
  1. @caridy
  2. @caridy
  3. @caridy
  4. @caridy
Commits on Jan 23, 2013
  1. @caridy

    updating PR with the latest from develop after 2.5.2, solving conflit…

    caridy authored
    …s generated by the hook system.
Commits on Jan 24, 2013
  1. @caridy
  2. @caridy

    cleaning tests mocks

    caridy authored
  3. @caridy
  4. @caridy
Commits on Jan 28, 2013
  1. @caridy
Commits on Jan 29, 2013
  1. @caridy
  2. @caridy
Something went wrong with that request. Please try again.