This repository has been archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 214
[bz5800733] Handlebars Template Helpers (second attempt after #922) #1011
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…on of req in the server and doc in the client. This structure could be use to store data per request on the server and per page on the client. at the moment, this structure will not be serialized or used after the dispatcher ends
…n rendering a particular view using HB
…l adapter.page object to expose models per request. also, changing the api to align with helpers
…at mojito-models-addon uses. this is experimental in 0.5.5
ping issue #922 |
@@ -30,6 +30,7 @@ var NAME = 'OutputHandler.server', | |||
this.res = res; | |||
this.next = next; | |||
this.headers = {}; | |||
this.page = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooooooh, me like.
+2 |
caridy
added a commit
that referenced
this pull request
Feb 26, 2013
Closes PR #922. Fixes bz5800733. Adds support for handlebars template helpers thru mojito-helpers-addon. Consolidates mojito-models-addon api.
@gotwarlost check this out, released in 0.5.5 today |
already incorporated :) |
Just keep in mind that this feature is EXPERIMENTAL and API might change in the future. If you use it, and it is fine to use it, you will be in the bleeding edge of mojito :). |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces the concept of helpers thru an addon called
mojito-helpers-addon
. Any mojito requiring this addon will be able to:API
ac.helpers.set(name, func)
to set a local helperac.helpers.get(name)
in case you want to get a handler on a global or even local that was registered somewhereac.helpers.expose(name, func)
to make it available locally but also exposing it globallyac.helpers.expose(name)
in case you want to expose an existing helper.How does it work?
Under the hood, any helper function, locally set using
ac.helpers.set()
or globally exposed by any of the parent mojits usingac.helpers.expose()
will be passed into the handlebars render engine, so you can use them in your templates/views.Limitations and things to keep in mind
mojitProxy.render()
ormojitProxy.refreshView()
, only thrumojitProxy.invoke()
.mojitProxy.invoke()
if the helper is supposed to be defined by another mojit that was not instantiated prior to the invoke.Examples
https://github.com/caridy/mojito-demos/tree/master/mojito-helpers