-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4912de
commit 25850a8
Showing
7 changed files
with
172 additions
and
26 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# ax5.mustache | ||
|
||
> "ax5.mustache" is a modified version of the in the "https://github.com/janl/mustache.js", some of the syntax. | ||
## ax5.mustache.render | ||
`ax5.mustache.render(tmpl, view)` | ||
|
||
```js | ||
var view = { | ||
title: "Joe", | ||
calc: function () { | ||
return 2 + 4; | ||
} | ||
}; | ||
|
||
var output = ax5.mustache.render("{{title}} spends {{calc}}", view); | ||
``` | ||
Please refer to the `mustache` API is about the template. | ||
this version added only a few of the key and function in the `mustache`. | ||
[Mustache API](https://github.com/janl/mustache.js/blob/master/README.md) | ||
You can use all of the API of `mustache` in the same way. I will introduce the features added in the `ax5.mustache` below. | ||
|
||
|
||
## Array | ||
|
||
View: | ||
```js | ||
{ | ||
"beatles": [ | ||
{ "firstName": "John", "lastName": "Lennon" }, | ||
{ "firstName": "Paul", "lastName": "McCartney" }, | ||
{ "firstName": "George", "lastName": "Harrison" }, | ||
{ "firstName": "Ringo", "lastName": "Star" } | ||
] | ||
} | ||
``` | ||
|
||
Template: | ||
``` | ||
{{#beatles}} | ||
* {{firstName}} {{lastName}} ({{@i}}) ({{@first}}) | ||
{{/beatles}} | ||
``` | ||
|
||
Output: | ||
``` | ||
* John Lennon (0) (true) | ||
* Paul McCartney (1) (false) | ||
* George Harrison (2) (false) | ||
* Ringo Star (3) (false) | ||
``` | ||
|
||
## Object.getEach | ||
|
||
View: | ||
```js | ||
{ | ||
"beatles": { | ||
"John": {"firstName": "John", "lastName": "Lennon"}, | ||
"Paul": {"firstName": "Paul", "lastName": "McCartney"}, | ||
"George": {"firstName": "George", "lastName": "Harrison"}, | ||
"Ringo": {"firstName": "Ringo", "lastName": "Star"} | ||
} | ||
} | ||
``` | ||
|
||
Template: | ||
``` | ||
{{#beatles}} | ||
{{#getEach}} | ||
* {{@key}} : {{@value.firstName}} {{@value.lastName}} | ||
{{/getEach}} | ||
{{/beatles}} | ||
``` | ||
|
||
Output: | ||
``` | ||
* John : John Lennon | ||
* Paul : Paul McCartney | ||
* George : George Harrison | ||
* Ringo : Ringo Star | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "ax5core", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"authors": [ | ||
"ThomasJ <[email protected]>" | ||
], | ||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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