forked from Mirrors/node-red-contrib-mi-devices
Removed node_modules, add mustache to package.json
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
|
||||
*.iml
|
||||
|
||||
/node_modules
|
||||
|
||||
1
node-red-contrib-xiaomi-ht/node_modules/.bin/mustache
generated
vendored
1
node-red-contrib-xiaomi-ht/node_modules/.bin/mustache
generated
vendored
@@ -1 +0,0 @@
|
||||
../mustache/bin/mustache
|
||||
284
node-red-contrib-xiaomi-ht/node_modules/mustache/CHANGELOG.md
generated
vendored
284
node-red-contrib-xiaomi-ht/node_modules/mustache/CHANGELOG.md
generated
vendored
@@ -1,284 +0,0 @@
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [2.3.0] / 8 November 2016
|
||||
|
||||
### Minor
|
||||
|
||||
* [#540]: Add optional `output` argument to mustache CLI, by [@wizawu].
|
||||
* [#597]: Add compatibility with amdclean, by [@mightyplow].
|
||||
|
||||
### Dev
|
||||
|
||||
* [#553]: Assert `null` lookup when rendering an unescaped value, by [@dasilvacontin].
|
||||
* [#580], [#610]: Ignore eslint for greenkeeper updates, by [@phillipj].
|
||||
* [#560]: Fix CLI tests for Windows, by [@kookookchoozeus].
|
||||
* Run browser tests w/node v4, by [@phillipj].
|
||||
|
||||
### Docs
|
||||
|
||||
* [#542]: Add API documentation to README, by [@tomekwi].
|
||||
* [#546]: Add missing syntax highlighting to README code blocks, by [@pra85].
|
||||
* [#569]: Update Ctemplate links in README, by [@mortonfox].
|
||||
* [#592]: Change "loadUser" to "loadUser()" in README, by [@Flaque].
|
||||
* [#593]: Adding doctype to HTML code example in README, by [@calvinf].
|
||||
|
||||
### Dependencies
|
||||
|
||||
* eslint -> 2.2.0. Breaking changes fix by [@phillipj]. [#548]
|
||||
* eslint -> 2.5.1.
|
||||
* mocha -> 3.0.2.
|
||||
* zuul -> 3.11.0.
|
||||
|
||||
## [2.2.1] / 13 December 2015
|
||||
|
||||
### Fixes
|
||||
|
||||
* Improve HTML escaping, by [@phillipj].
|
||||
* Fix inconsistency in defining global mustache object, by [@simast].
|
||||
* Fix switch-case indent error, by [@norfish].
|
||||
* Unpin chai and eslint versions, by [@dasilvacontin].
|
||||
* Update README.md with proper grammar, by [@EvanLovely].
|
||||
* Update mjackson username in README, by [@mjackson].
|
||||
* Remove syntax highlighting in README code sample, by [@imagentleman].
|
||||
* Fix typo in README, by [@Xcrucifier].
|
||||
* Fix link typo in README, by [@keirog].
|
||||
|
||||
## [2.2.0] / 15 October 2015
|
||||
|
||||
### Added
|
||||
|
||||
* Add Partials support to CLI, by [@palkan].
|
||||
|
||||
### Changed
|
||||
|
||||
* Move install instructions to README's top, by [@mateusortiz]
|
||||
* Improved devhook install output, by [@ShashankaNataraj].
|
||||
* Clarifies and improves language in documentation, by [@jfmercer].
|
||||
* Linting CLI tool, by [@phillipj].
|
||||
* npm 2.x and node v4 on Travis, by [@phillipj].
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix README spelling error to "aforementioned", by [@djchie].
|
||||
* Equal error message test in .render() for server and browser, by [@phillipj].
|
||||
|
||||
### Dependencies
|
||||
|
||||
* chai -> 3.3.0
|
||||
* eslint -> 1.6.0
|
||||
|
||||
## [2.1.3] / 23 July 2015
|
||||
|
||||
### Added
|
||||
|
||||
* Throw error when providing .render() with invalid template type, by [@phillipj].
|
||||
* Documents use of string literals containing double quotes, by [@jfmercer].
|
||||
|
||||
### Changed
|
||||
|
||||
* Move mustache gif to githubusercontent, by [@Andersos].
|
||||
|
||||
### Fixed
|
||||
|
||||
* Update UMD Shim to be resilient to HTMLElement global pollution, by [@mikesherov].
|
||||
|
||||
## [2.1.2] / 17 June 2015
|
||||
|
||||
### Added
|
||||
|
||||
* Mustache global definition ([#466]) by [@yousefcisco].
|
||||
|
||||
## [2.1.1] / 11 June 2015
|
||||
|
||||
### Added
|
||||
|
||||
* State that we use semver on the change log, by [@dasilvacontin].
|
||||
* Added version links to change log, by [@dasilvacontin].
|
||||
|
||||
### Fixed
|
||||
|
||||
* Bugfix for using values from view's context prototype, by [@phillipj].
|
||||
* Improve test with undefined/null lookup hit using dot notation, by [@dasilvacontin].
|
||||
* Bugfix for null/undefined lookup hit when using dot notation, by [@phillipj].
|
||||
* Remove moot `version` property from bower.json, by [@kkirsche].
|
||||
* bower.json doesn't require a version bump via hook, by [@dasilvacontin].
|
||||
|
||||
|
||||
## [2.1.0] / 5 June 2015
|
||||
|
||||
* Added license attribute to package.json, by [@pgilad].
|
||||
* Minor changes to make mustache.js compatible with both WSH and ASP, by [@nagaozen].
|
||||
* Improve CLI view parsing error, by [@phillipj].
|
||||
* Bugfix for view context cache, by [@phillipj].
|
||||
|
||||
## [2.0.0] / 27 Mar 2015
|
||||
|
||||
* Fixed lookup not stopping upon finding `undefined` or `null` values, by [@dasilvacontin].
|
||||
* Refactored pre-commit hook, by [@dasilvacontin].
|
||||
|
||||
## [1.2.0] / 24 Mar 2015
|
||||
|
||||
* Added -v option to CLI, by [@phillipj].
|
||||
* Bugfix for rendering Number when it serves as the Context, by [@phillipj].
|
||||
* Specified files in package.json for a cleaner install, by [@phillipj].
|
||||
|
||||
## [1.1.0] / 18 Feb 2015
|
||||
|
||||
* Refactor Writer.renderTokens() for better readability, by [@phillipj].
|
||||
* Cleanup tests section in readme, by [@phillipj].
|
||||
* Added JSHint to tests/CI, by [@phillipj].
|
||||
* Added node v0.12 on travis, by [@phillipj].
|
||||
* Created command line tool, by [@phillipj].
|
||||
* Added *falsy* to Inverted Sections description in README, by [@kristijanmatic].
|
||||
|
||||
## [1.0.0] / 20 Dec 2014
|
||||
|
||||
* Inline tag compilation, by [@mjackson].
|
||||
* Fixed AMD registration, volo package.json entry, by [@jrburke].
|
||||
* Added spm support, by [@afc163].
|
||||
* Only access properties of objects on Context.lookup, by [@cmbuckley].
|
||||
|
||||
## [0.8.2] / 17 Mar 2014
|
||||
|
||||
* Supporting Bower through a bower.json file.
|
||||
|
||||
## [0.8.1] / 3 Jan 2014
|
||||
|
||||
* Fix usage of partial templates.
|
||||
|
||||
## [0.8.0] / 2 Dec 2013
|
||||
|
||||
* Remove compile* writer functions, use mustache.parse instead. Smaller API.
|
||||
* Throw an error when rendering a template that contains higher-order sections and
|
||||
the original template is not provided.
|
||||
* Remove low-level Context.make function.
|
||||
* Better code readability and inline documentation.
|
||||
* Stop caching templates by name.
|
||||
|
||||
## [0.7.3] / 5 Nov 2013
|
||||
|
||||
* Don't require the original template to be passed to the rendering function
|
||||
when using compiled templates. This is still required when using higher-order
|
||||
functions in order to be able to extract the portion of the template
|
||||
that was contained by that section. Fixes [#262].
|
||||
* Performance improvements.
|
||||
|
||||
## [0.7.2] / 27 Dec 2012
|
||||
|
||||
* Fixed a rendering bug ([#274]) when using nested higher-order sections.
|
||||
* Better error reporting on failed parse.
|
||||
* Converted tests to use mocha instead of vows.
|
||||
|
||||
## [0.7.1] / 6 Dec 2012
|
||||
|
||||
* Handle empty templates gracefully. Fixes [#265], [#267], and [#270].
|
||||
* Cache partials by template, not by name. Fixes [#257].
|
||||
* Added Mustache.compileTokens to compile the output of Mustache.parse. Fixes
|
||||
[#258].
|
||||
|
||||
## [0.7.0] / 10 Sep 2012
|
||||
|
||||
* Rename Renderer => Writer.
|
||||
* Allow partials to be loaded dynamically using a callback (thanks
|
||||
[@TiddoLangerak] for the suggestion).
|
||||
* Fixed a bug with higher-order sections that prevented them from being
|
||||
passed the raw text of the section from the original template.
|
||||
* More concise token format. Tokens also include start/end indices in the
|
||||
original template.
|
||||
* High-level API is consistent with the Writer API.
|
||||
* Allow partials to be passed to the pre-compiled function (thanks
|
||||
[@fallenice]).
|
||||
* Don't use eval (thanks [@cweider]).
|
||||
|
||||
## [0.6.0] / 31 Aug 2012
|
||||
|
||||
* Use JavaScript's definition of falsy when determining whether to render an
|
||||
inverted section or not. Issue [#186].
|
||||
* Use Mustache.escape to escape values inside {{}}. This function may be
|
||||
reassigned to alter the default escaping behavior. Issue [#244].
|
||||
* Fixed a bug that clashed with QUnit (thanks [@kannix]).
|
||||
* Added volo support (thanks [@guybedford]).
|
||||
|
||||
[2.3.0]: https://github.com/janl/mustache.js/compare/v2.2.1...v2.3.0
|
||||
[2.2.1]: https://github.com/janl/mustache.js/compare/v2.2.0...v2.2.1
|
||||
[2.2.0]: https://github.com/janl/mustache.js/compare/v2.1.3...v2.2.0
|
||||
[2.1.3]: https://github.com/janl/mustache.js/compare/v2.1.2...v2.1.3
|
||||
[2.1.2]: https://github.com/janl/mustache.js/compare/v2.1.1...v2.1.2
|
||||
[2.1.1]: https://github.com/janl/mustache.js/compare/v2.1.0...v2.1.1
|
||||
[2.1.0]: https://github.com/janl/mustache.js/compare/v2.0.0...v2.1.0
|
||||
[2.0.0]: https://github.com/janl/mustache.js/compare/v1.2.0...v2.0.0
|
||||
[1.2.0]: https://github.com/janl/mustache.js/compare/v1.1.0...v1.2.0
|
||||
[1.1.0]: https://github.com/janl/mustache.js/compare/v1.0.0...v1.1.0
|
||||
[1.0.0]: https://github.com/janl/mustache.js/compare/0.8.2...v1.0.0
|
||||
[0.8.2]: https://github.com/janl/mustache.js/compare/0.8.1...0.8.2
|
||||
[0.8.1]: https://github.com/janl/mustache.js/compare/0.8.0...0.8.1
|
||||
[0.8.0]: https://github.com/janl/mustache.js/compare/0.7.3...0.8.0
|
||||
[0.7.3]: https://github.com/janl/mustache.js/compare/0.7.2...0.7.3
|
||||
[0.7.2]: https://github.com/janl/mustache.js/compare/0.7.1...0.7.2
|
||||
[0.7.1]: https://github.com/janl/mustache.js/compare/0.7.0...0.7.1
|
||||
[0.7.0]: https://github.com/janl/mustache.js/compare/0.6.0...0.7.0
|
||||
[0.6.0]: https://github.com/janl/mustache.js/compare/0.5.2...0.6.0
|
||||
|
||||
[#186]: https://github.com/janl/mustache.js/issues/186
|
||||
[#244]: https://github.com/janl/mustache.js/issues/244
|
||||
[#257]: https://github.com/janl/mustache.js/issues/257
|
||||
[#258]: https://github.com/janl/mustache.js/issues/258
|
||||
[#262]: https://github.com/janl/mustache.js/issues/262
|
||||
[#265]: https://github.com/janl/mustache.js/issues/265
|
||||
[#267]: https://github.com/janl/mustache.js/issues/267
|
||||
[#270]: https://github.com/janl/mustache.js/issues/270
|
||||
[#274]: https://github.com/janl/mustache.js/issues/274
|
||||
[#466]: https://github.com/janl/mustache.js/issues/466
|
||||
[#540]: https://github.com/janl/mustache.js/issues/540
|
||||
[#542]: https://github.com/janl/mustache.js/issues/542
|
||||
[#546]: https://github.com/janl/mustache.js/issues/546
|
||||
[#548]: https://github.com/janl/mustache.js/issues/548
|
||||
[#553]: https://github.com/janl/mustache.js/issues/553
|
||||
[#560]: https://github.com/janl/mustache.js/issues/560
|
||||
[#569]: https://github.com/janl/mustache.js/issues/569
|
||||
[#580]: https://github.com/janl/mustache.js/issues/580
|
||||
[#592]: https://github.com/janl/mustache.js/issues/592
|
||||
[#593]: https://github.com/janl/mustache.js/issues/593
|
||||
[#597]: https://github.com/janl/mustache.js/issues/597
|
||||
[#610]: https://github.com/janl/mustache.js/issues/610
|
||||
|
||||
[@afc163]: https://github.com/afc163
|
||||
[@Andersos]: https://github.com/Andersos
|
||||
[@calvinf]: https://github.com/calvinf
|
||||
[@cmbuckley]: https://github.com/cmbuckley
|
||||
[@cweider]: https://github.com/cweider
|
||||
[@dasilvacontin]: https://github.com/dasilvacontin
|
||||
[@djchie]: https://github.com/djchie
|
||||
[@EvanLovely]: https://github.com/EvanLovely
|
||||
[@fallenice]: https://github.com/fallenice
|
||||
[@Flaque]: https://github.com/Flaque
|
||||
[@guybedford]: https://github.com/guybedford
|
||||
[@imagentleman]: https://github.com/imagentleman
|
||||
[@jfmercer]: https://github.com/jfmercer
|
||||
[@jrburke]: https://github.com/jrburke
|
||||
[@kannix]: https://github.com/kannix
|
||||
[@keirog]: https://github.com/keirog
|
||||
[@kkirsche]: https://github.com/kkirsche
|
||||
[@kookookchoozeus]: https://github.com/kookookchoozeus
|
||||
[@kristijanmatic]: https://github.com/kristijanmatic
|
||||
[@mateusortiz]: https://github.com/mateusortiz
|
||||
[@mightyplow]: https://github.com/mightyplow
|
||||
[@mikesherov]: https://github.com/mikesherov
|
||||
[@mjackson]: https://github.com/mjackson
|
||||
[@mortonfox]: https://github.com/mortonfox
|
||||
[@nagaozen]: https://github.com/nagaozen
|
||||
[@norfish]: https://github.com/norfish
|
||||
[@palkan]: https://github.com/palkan
|
||||
[@pgilad]: https://github.com/pgilad
|
||||
[@phillipj]: https://github.com/phillipj
|
||||
[@pra85]: https://github.com/pra85
|
||||
[@ShashankaNataraj]: https://github.com/ShashankaNataraj
|
||||
[@simast]: https://github.com/simast
|
||||
[@TiddoLangerak]: https://github.com/TiddoLangerak
|
||||
[@tomekwi]: https://github.com/tomekwi
|
||||
[@wizawu]: https://github.com/wizawu
|
||||
[@Xcrucifier]: https://github.com/Xcrucifier
|
||||
[@yousefcisco]: https://github.com/yousefcisco
|
||||
11
node-red-contrib-xiaomi-ht/node_modules/mustache/LICENSE
generated
vendored
11
node-red-contrib-xiaomi-ht/node_modules/mustache/LICENSE
generated
vendored
@@ -1,11 +0,0 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2009 Chris Wanstrath (Ruby)
|
||||
Copyright (c) 2010-2014 Jan Lehnardt (JavaScript)
|
||||
Copyright (c) 2010-2015 The mustache.js community
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
639
node-red-contrib-xiaomi-ht/node_modules/mustache/README.md
generated
vendored
639
node-red-contrib-xiaomi-ht/node_modules/mustache/README.md
generated
vendored
@@ -1,639 +0,0 @@
|
||||
# mustache.js - Logic-less {{mustache}} templates with JavaScript
|
||||
|
||||
> What could be more logical awesome than no logic at all?
|
||||
|
||||
[](https://travis-ci.org/janl/mustache.js) [](https://gitter.im/janl/mustache.js)
|
||||
|
||||
[mustache.js](http://github.com/janl/mustache.js) is an implementation of the [mustache](http://mustache.github.com/) template system in JavaScript.
|
||||
|
||||
[Mustache](http://mustache.github.com/) is a logic-less template syntax. It can be used for HTML, config files, source code - anything. It works by expanding tags in a template using values provided in a hash or object.
|
||||
|
||||
We call it "logic-less" because there are no if statements, else clauses, or for loops. Instead there are only tags. Some tags are replaced with a value, some nothing, and others a series of values.
|
||||
|
||||
For a language-agnostic overview of mustache's template syntax, see the `mustache(5)` [manpage](http://mustache.github.com/mustache.5.html).
|
||||
|
||||
## Where to use mustache.js?
|
||||
|
||||
You can use mustache.js to render mustache templates anywhere you can use JavaScript. This includes web browsers, server-side environments such as [node](http://nodejs.org/), and [CouchDB](http://couchdb.apache.org/) views.
|
||||
|
||||
mustache.js ships with support for both the [CommonJS](http://www.commonjs.org/) module API and the [Asynchronous Module Definition](https://github.com/amdjs/amdjs-api/wiki/AMD) API, or AMD.
|
||||
|
||||
And this will be your templates after you use Mustache:
|
||||
|
||||

|
||||
|
||||
## Install
|
||||
|
||||
You can get Mustache via npm.
|
||||
|
||||
```bash
|
||||
$ npm install mustache --save
|
||||
```
|
||||
or install with bower:
|
||||
|
||||
```bash
|
||||
$ bower install --save mustache
|
||||
```
|
||||
|
||||
## Command line tool
|
||||
|
||||
mustache.js is shipped with a node based command line tool. It might be installed as a global tool on your computer to render a mustache template of some kind
|
||||
|
||||
```bash
|
||||
$ npm install -g mustache
|
||||
|
||||
$ mustache dataView.json myTemplate.mustache > output.html
|
||||
```
|
||||
|
||||
also supports stdin.
|
||||
|
||||
```bash
|
||||
$ cat dataView.json | mustache - myTemplate.mustache > output.html
|
||||
```
|
||||
|
||||
or as a package.json `devDependency` in a build process maybe?
|
||||
|
||||
```bash
|
||||
$ npm install mustache --save-dev
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"build": "mustache dataView.json myTemplate.mustache > public/output.html"
|
||||
}
|
||||
}
|
||||
```
|
||||
```bash
|
||||
$ npm run build
|
||||
```
|
||||
|
||||
The command line tool is basically a wrapper around `Mustache.render` so you get all the features.
|
||||
|
||||
If your templates use partials you should pass paths to partials using `-p` flag:
|
||||
|
||||
```bash
|
||||
$ mustache -p path/to/partial1.mustache -p path/to/partial2.mustache dataView.json myTemplate.mustache
|
||||
```
|
||||
|
||||
## Who uses mustache.js?
|
||||
|
||||
An updated list of mustache.js users is kept [on the Github wiki](http://wiki.github.com/janl/mustache.js/beard-competition). Add yourself or your company if you use mustache.js!
|
||||
|
||||
## Contributing
|
||||
|
||||
mustache.js is a mature project, but it continues to actively invite maintainers. You can help out a high-profile project that is used in a lot of places on the web. There is [plenty](https://github.com/janl/mustache.js/issues) of [work](https://github.com/janl/mustache.js/pulls) to do. No big commitment required, if all you do is review a single [Pull Request](https://github.com/janl/mustache.js/pulls), you are a maintainer. And a hero.
|
||||
|
||||
### Your First Contribution
|
||||
|
||||
- review a [Pull Request](https://github.com/janl/mustache.js/pulls)
|
||||
- fix an [Issue](https://github.com/janl/mustache.js/issues)
|
||||
- update the [documentation](https://github.com/janl/mustache.js#usage)
|
||||
- make a website
|
||||
- write a tutorial
|
||||
|
||||
* * *
|
||||
|
||||
## Usage
|
||||
|
||||
Below is a quick example how to use mustache.js:
|
||||
|
||||
```js
|
||||
var view = {
|
||||
title: "Joe",
|
||||
calc: function () {
|
||||
return 2 + 4;
|
||||
}
|
||||
};
|
||||
|
||||
var output = Mustache.render("{{title}} spends {{calc}}", view);
|
||||
```
|
||||
|
||||
In this example, the `Mustache.render` function takes two parameters: 1) the [mustache](http://mustache.github.com/) template and 2) a `view` object that contains the data and code needed to render the template.
|
||||
|
||||
## API
|
||||
|
||||
Following is an [rtype](https://git.io/rtype) signature of the most commonly used functions.
|
||||
|
||||
```js
|
||||
Mustache.render(
|
||||
template : String,
|
||||
view : Object,
|
||||
partials? : Object,
|
||||
) => String
|
||||
|
||||
Mustache.parse(
|
||||
template : String,
|
||||
tags = ['{{', '}}'] : Tags,
|
||||
) => String
|
||||
|
||||
interface Tags [String, String]
|
||||
```
|
||||
|
||||
## Templates
|
||||
|
||||
A [mustache](http://mustache.github.com/) template is a string that contains any number of mustache tags. Tags are indicated by the double mustaches that surround them. `{{person}}` is a tag, as is `{{#person}}`. In both examples we refer to `person` as the tag's key. There are several types of tags available in mustache.js, described below.
|
||||
|
||||
There are several techniques that can be used to load templates and hand them to mustache.js, here are two of them:
|
||||
|
||||
#### Include Templates
|
||||
|
||||
If you need a template for a dynamic part in a static website, you can consider including the template in the static HTML file to avoid loading templates separately. Here's a small example using `jQuery`:
|
||||
|
||||
```html
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body onload="loadUser()">
|
||||
<div id="target">Loading...</div>
|
||||
<script id="template" type="x-tmpl-mustache">
|
||||
Hello {{ name }}!
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
```js
|
||||
function loadUser() {
|
||||
var template = $('#template').html();
|
||||
Mustache.parse(template); // optional, speeds up future uses
|
||||
var rendered = Mustache.render(template, {name: "Luke"});
|
||||
$('#target').html(rendered);
|
||||
}
|
||||
```
|
||||
|
||||
#### Load External Templates
|
||||
|
||||
If your templates reside in individual files, you can load them asynchronously and render them when they arrive. Another example using `jQuery`:
|
||||
|
||||
```js
|
||||
function loadUser() {
|
||||
$.get('template.mst', function(template) {
|
||||
var rendered = Mustache.render(template, {name: "Luke"});
|
||||
$('#target').html(rendered);
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### Variables
|
||||
|
||||
The most basic tag type is a simple variable. A `{{name}}` tag renders the value of the `name` key in the current context. If there is no such key, nothing is rendered.
|
||||
|
||||
All variables are HTML-escaped by default. If you want to render unescaped HTML, use the triple mustache: `{{{name}}}`. You can also use `&` to unescape a variable.
|
||||
|
||||
If you want `{{name}}` _not_ to be interpreted as a mustache tag, but rather to appear exactly as `{{name}}` in the output, you must change and then restore the default delimiter. See the [Custom Delimiters](#custom-delimiters) section for more information.
|
||||
|
||||
View:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Chris",
|
||||
"company": "<b>GitHub</b>"
|
||||
}
|
||||
```
|
||||
|
||||
Template:
|
||||
|
||||
```
|
||||
* {{name}}
|
||||
* {{age}}
|
||||
* {{company}}
|
||||
* {{{company}}}
|
||||
* {{&company}}
|
||||
{{=<% %>=}}
|
||||
* {{company}}
|
||||
<%={{ }}=%>
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```html
|
||||
* Chris
|
||||
*
|
||||
* <b>GitHub</b>
|
||||
* <b>GitHub</b>
|
||||
* <b>GitHub</b>
|
||||
* {{company}}
|
||||
```
|
||||
|
||||
JavaScript's dot notation may be used to access keys that are properties of objects in a view.
|
||||
|
||||
View:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": {
|
||||
"first": "Michael",
|
||||
"last": "Jackson"
|
||||
},
|
||||
"age": "RIP"
|
||||
}
|
||||
```
|
||||
|
||||
Template:
|
||||
|
||||
```html
|
||||
* {{name.first}} {{name.last}}
|
||||
* {{age}}
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```html
|
||||
* Michael Jackson
|
||||
* RIP
|
||||
```
|
||||
|
||||
### Sections
|
||||
|
||||
Sections render blocks of text one or more times, depending on the value of the key in the current context.
|
||||
|
||||
A section begins with a pound and ends with a slash. That is, `{{#person}}` begins a `person` section, while `{{/person}}` ends it. The text between the two tags is referred to as that section's "block".
|
||||
|
||||
The behavior of the section is determined by the value of the key.
|
||||
|
||||
#### False Values or Empty Lists
|
||||
|
||||
If the `person` key does not exist, or exists and has a value of `null`, `undefined`, `false`, `0`, or `NaN`, or is an empty string or an empty list, the block will not be rendered.
|
||||
|
||||
View:
|
||||
|
||||
```json
|
||||
{
|
||||
"person": false
|
||||
}
|
||||
```
|
||||
|
||||
Template:
|
||||
|
||||
```html
|
||||
Shown.
|
||||
{{#person}}
|
||||
Never shown!
|
||||
{{/person}}
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```html
|
||||
Shown.
|
||||
```
|
||||
|
||||
#### Non-Empty Lists
|
||||
|
||||
If the `person` key exists and is not `null`, `undefined`, or `false`, and is not an empty list the block will be rendered one or more times.
|
||||
|
||||
When the value is a list, the block is rendered once for each item in the list. The context of the block is set to the current item in the list for each iteration. In this way we can loop over collections.
|
||||
|
||||
View:
|
||||
|
||||
```json
|
||||
{
|
||||
"stooges": [
|
||||
{ "name": "Moe" },
|
||||
{ "name": "Larry" },
|
||||
{ "name": "Curly" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Template:
|
||||
|
||||
```html
|
||||
{{#stooges}}
|
||||
<b>{{name}}</b>
|
||||
{{/stooges}}
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```html
|
||||
<b>Moe</b>
|
||||
<b>Larry</b>
|
||||
<b>Curly</b>
|
||||
```
|
||||
|
||||
When looping over an array of strings, a `.` can be used to refer to the current item in the list.
|
||||
|
||||
View:
|
||||
|
||||
```json
|
||||
{
|
||||
"musketeers": ["Athos", "Aramis", "Porthos", "D'Artagnan"]
|
||||
}
|
||||
```
|
||||
|
||||
Template:
|
||||
|
||||
```html
|
||||
{{#musketeers}}
|
||||
* {{.}}
|
||||
{{/musketeers}}
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```html
|
||||
* Athos
|
||||
* Aramis
|
||||
* Porthos
|
||||
* D'Artagnan
|
||||
```
|
||||
|
||||
If the value of a section variable is a function, it will be called in the context of the current item in the list on each iteration.
|
||||
|
||||
View:
|
||||
|
||||
```js
|
||||
{
|
||||
"beatles": [
|
||||
{ "firstName": "John", "lastName": "Lennon" },
|
||||
{ "firstName": "Paul", "lastName": "McCartney" },
|
||||
{ "firstName": "George", "lastName": "Harrison" },
|
||||
{ "firstName": "Ringo", "lastName": "Starr" }
|
||||
],
|
||||
"name": function () {
|
||||
return this.firstName + " " + this.lastName;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Template:
|
||||
|
||||
```html
|
||||
{{#beatles}}
|
||||
* {{name}}
|
||||
{{/beatles}}
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```html
|
||||
* John Lennon
|
||||
* Paul McCartney
|
||||
* George Harrison
|
||||
* Ringo Starr
|
||||
```
|
||||
|
||||
#### Functions
|
||||
|
||||
If the value of a section key is a function, it is called with the section's literal block of text, un-rendered, as its first argument. The second argument is a special rendering function that uses the current view as its view argument. It is called in the context of the current view object.
|
||||
|
||||
View:
|
||||
|
||||
```js
|
||||
{
|
||||
"name": "Tater",
|
||||
"bold": function () {
|
||||
return function (text, render) {
|
||||
return "<b>" + render(text) + "</b>";
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Template:
|
||||
|
||||
```html
|
||||
{{#bold}}Hi {{name}}.{{/bold}}
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```html
|
||||
<b>Hi Tater.</b>
|
||||
```
|
||||
|
||||
### Inverted Sections
|
||||
|
||||
An inverted section opens with `{{^section}}` instead of `{{#section}}`. The block of an inverted section is rendered only if the value of that section's tag is `null`, `undefined`, `false`, *falsy* or an empty list.
|
||||
|
||||
View:
|
||||
|
||||
```json
|
||||
{
|
||||
"repos": []
|
||||
}
|
||||
```
|
||||
|
||||
Template:
|
||||
|
||||
```html
|
||||
{{#repos}}<b>{{name}}</b>{{/repos}}
|
||||
{{^repos}}No repos :({{/repos}}
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```html
|
||||
No repos :(
|
||||
```
|
||||
|
||||
### Comments
|
||||
|
||||
Comments begin with a bang and are ignored. The following template:
|
||||
|
||||
```html
|
||||
<h1>Today{{! ignore me }}.</h1>
|
||||
```
|
||||
|
||||
Will render as follows:
|
||||
|
||||
```html
|
||||
<h1>Today.</h1>
|
||||
```
|
||||
|
||||
Comments may contain newlines.
|
||||
|
||||
### Partials
|
||||
|
||||
Partials begin with a greater than sign, like {{> box}}.
|
||||
|
||||
Partials are rendered at runtime (as opposed to compile time), so recursive partials are possible. Just avoid infinite loops.
|
||||
|
||||
They also inherit the calling context. Whereas in ERB you may have this:
|
||||
|
||||
```html+erb
|
||||
<%= partial :next_more, :start => start, :size => size %>
|
||||
```
|
||||
|
||||
Mustache requires only this:
|
||||
|
||||
```html
|
||||
{{> next_more}}
|
||||
```
|
||||
|
||||
Why? Because the `next_more.mustache` file will inherit the `size` and `start` variables from the calling context. In this way you may want to think of partials as includes, imports, template expansion, nested templates, or subtemplates, even though those aren't literally the case here.
|
||||
|
||||
|
||||
For example, this template and partial:
|
||||
|
||||
base.mustache:
|
||||
<h2>Names</h2>
|
||||
{{#names}}
|
||||
{{> user}}
|
||||
{{/names}}
|
||||
|
||||
user.mustache:
|
||||
<strong>{{name}}</strong>
|
||||
|
||||
Can be thought of as a single, expanded template:
|
||||
|
||||
```html
|
||||
<h2>Names</h2>
|
||||
{{#names}}
|
||||
<strong>{{name}}</strong>
|
||||
{{/names}}
|
||||
```
|
||||
|
||||
In mustache.js an object of partials may be passed as the third argument to `Mustache.render`. The object should be keyed by the name of the partial, and its value should be the partial text.
|
||||
|
||||
```js
|
||||
Mustache.render(template, view, {
|
||||
user: userTemplate
|
||||
});
|
||||
```
|
||||
|
||||
### Custom Delimiters
|
||||
|
||||
Custom delimiters can be used in place of `{{` and `}}` by setting the new values in JavaScript or in templates.
|
||||
|
||||
#### Setting in JavaScript
|
||||
|
||||
The `Mustache.tags` property holds an array consisting of the opening and closing tag values. Set custom values by passing a new array of tags to `parse()`, which gets honored over the default values, or by overriding the `tags` property itself:
|
||||
|
||||
```js
|
||||
var customTags = [ '<%', '%>' ];
|
||||
```
|
||||
|
||||
##### Pass Value into Parse Method
|
||||
```js
|
||||
Mustache.parse(template, customTags);
|
||||
```
|
||||
|
||||
##### Override Tags Property
|
||||
```js
|
||||
Mustache.tags = customTags;
|
||||
// Subsequent parse() and render() calls will use customTags
|
||||
```
|
||||
|
||||
#### Setting in Templates
|
||||
|
||||
Set Delimiter tags start with an equals sign and change the tag delimiters from `{{` and `}}` to custom strings.
|
||||
|
||||
Consider the following contrived example:
|
||||
|
||||
```html+erb
|
||||
* {{ default_tags }}
|
||||
{{=<% %>=}}
|
||||
* <% erb_style_tags %>
|
||||
<%={{ }}=%>
|
||||
* {{ default_tags_again }}
|
||||
```
|
||||
|
||||
Here we have a list with three items. The first item uses the default tag style, the second uses ERB style as defined by the Set Delimiter tag, and the third returns to the default style after yet another Set Delimiter declaration.
|
||||
|
||||
According to [ctemplates](https://htmlpreview.github.io/?https://raw.githubusercontent.com/OlafvdSpek/ctemplate/master/doc/howto.html), this "is useful for languages like TeX, where double-braces may occur in the text and are awkward to use for markup."
|
||||
|
||||
Custom delimiters may not contain whitespace or the equals sign.
|
||||
|
||||
## Pre-parsing and Caching Templates
|
||||
|
||||
By default, when mustache.js first parses a template it keeps the full parsed token tree in a cache. The next time it sees that same template it skips the parsing step and renders the template much more quickly. If you'd like, you can do this ahead of time using `mustache.parse`.
|
||||
|
||||
```js
|
||||
Mustache.parse(template);
|
||||
|
||||
// Then, sometime later.
|
||||
Mustache.render(template, view);
|
||||
```
|
||||
|
||||
## Plugins for JavaScript Libraries
|
||||
|
||||
mustache.js may be built specifically for several different client libraries, including the following:
|
||||
|
||||
- [jQuery](http://jquery.com/)
|
||||
- [MooTools](http://mootools.net/)
|
||||
- [Dojo](http://www.dojotoolkit.org/)
|
||||
- [YUI](http://developer.yahoo.com/yui/)
|
||||
- [qooxdoo](http://qooxdoo.org/)
|
||||
|
||||
These may be built using [Rake](http://rake.rubyforge.org/) and one of the following commands:
|
||||
```bash
|
||||
$ rake jquery
|
||||
$ rake mootools
|
||||
$ rake dojo
|
||||
$ rake yui3
|
||||
$ rake qooxdoo
|
||||
```
|
||||
## Testing
|
||||
|
||||
In order to run the tests you'll need to install [node](http://nodejs.org/).
|
||||
|
||||
You also need to install the sub module containing [Mustache specifications](http://github.com/mustache/spec) in the project root.
|
||||
```bash
|
||||
$ git submodule init
|
||||
$ git submodule update
|
||||
```
|
||||
Install dependencies.
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
Then run the tests.
|
||||
```bash
|
||||
$ npm test
|
||||
```
|
||||
The test suite consists of both unit and integration tests. If a template isn't rendering correctly for you, you can make a test for it by doing the following:
|
||||
|
||||
1. Create a template file named `mytest.mustache` in the `test/_files`
|
||||
directory. Replace `mytest` with the name of your test.
|
||||
2. Create a corresponding view file named `mytest.js` in the same directory.
|
||||
This file should contain a JavaScript object literal enclosed in
|
||||
parentheses. See any of the other view files for an example.
|
||||
3. Create a file with the expected output in `mytest.txt` in the same
|
||||
directory.
|
||||
|
||||
Then, you can run the test with:
|
||||
```bash
|
||||
$ TEST=mytest npm run test-render
|
||||
```
|
||||
### Browser tests
|
||||
|
||||
Browser tests are not included in `npm test` as they run for too long, although they are ran automatically on Travis when merged into master. Run browser tests locally in any browser:
|
||||
```bash
|
||||
$ npm run test-browser-local
|
||||
```
|
||||
then point your browser to `http://localhost:8080/__zuul`
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
#### npm install fails
|
||||
|
||||
Ensure to have a recent version of npm installed. While developing this project requires npm with support for `^` version ranges.
|
||||
```bash
|
||||
$ npm install -g npm
|
||||
```
|
||||
## Thanks
|
||||
|
||||
mustache.js wouldn't kick ass if it weren't for these fine souls:
|
||||
|
||||
* Chris Wanstrath / defunkt
|
||||
* Alexander Lang / langalex
|
||||
* Sebastian Cohnen / tisba
|
||||
* J Chris Anderson / jchris
|
||||
* Tom Robinson / tlrobinson
|
||||
* Aaron Quint / quirkey
|
||||
* Douglas Crockford
|
||||
* Nikita Vasilyev / NV
|
||||
* Elise Wood / glytch
|
||||
* Damien Mathieu / dmathieu
|
||||
* Jakub Kuźma / qoobaa
|
||||
* Will Leinweber / will
|
||||
* dpree
|
||||
* Jason Smith / jhs
|
||||
* Aaron Gibralter / agibralter
|
||||
* Ross Boucher / boucher
|
||||
* Matt Sanford / mzsanford
|
||||
* Ben Cherry / bcherry
|
||||
* Michael Jackson / mjackson
|
||||
* Phillip Johnsen / phillipj
|
||||
* David da Silva Contín / dasilvacontin
|
||||
136
node-red-contrib-xiaomi-ht/node_modules/mustache/bin/mustache
generated
vendored
136
node-red-contrib-xiaomi-ht/node_modules/mustache/bin/mustache
generated
vendored
@@ -1,136 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var fs = require('fs'),
|
||||
path = require('path');
|
||||
|
||||
var Mustache = require('..');
|
||||
var pkg = require('../package');
|
||||
var partials = {};
|
||||
|
||||
var partialsPaths = [];
|
||||
var partialArgIndex = -1;
|
||||
|
||||
while ((partialArgIndex = process.argv.indexOf('-p')) > -1) {
|
||||
partialsPaths.push(process.argv.splice(partialArgIndex, 2)[1]);
|
||||
}
|
||||
|
||||
var viewArg = process.argv[2];
|
||||
var templateArg = process.argv[3];
|
||||
var outputArg = process.argv[4];
|
||||
|
||||
if (hasVersionArg()) {
|
||||
return console.log(pkg.version);
|
||||
}
|
||||
|
||||
if (!templateArg || !viewArg) {
|
||||
console.error('Syntax: mustache <view> <template> [output]');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
run(readPartials, readView, readTemplate, render, toStdout);
|
||||
|
||||
/**
|
||||
* Runs a list of functions as a waterfall.
|
||||
* Functions are runned one after the other in order, providing each
|
||||
* function the returned values of all the previously invoked functions.
|
||||
* Each function is expected to exit the process if an error occurs.
|
||||
*/
|
||||
function run (/*args*/) {
|
||||
var values = [];
|
||||
var fns = Array.prototype.slice.call(arguments);
|
||||
|
||||
function invokeNextFn (val) {
|
||||
values.unshift(val);
|
||||
if (fns.length === 0) return;
|
||||
invoke(fns.shift());
|
||||
}
|
||||
|
||||
function invoke (fn) {
|
||||
fn.apply(null, [invokeNextFn].concat(values));
|
||||
}
|
||||
|
||||
invoke(fns.shift());
|
||||
}
|
||||
|
||||
function readView (cb) {
|
||||
var view = isStdin(viewArg) ? process.openStdin() : fs.createReadStream(viewArg);
|
||||
|
||||
streamToStr(view, function onDone (str) {
|
||||
cb(parseView(str));
|
||||
});
|
||||
}
|
||||
|
||||
function parseView (str) {
|
||||
try {
|
||||
return JSON.parse(str);
|
||||
} catch (ex) {
|
||||
console.error(
|
||||
'Shooot, could not parse view as JSON.\n' +
|
||||
'Tips: functions are not valid JSON and keys / values must be surround with double quotes.\n\n' +
|
||||
ex.stack);
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
function readPartials (cb) {
|
||||
if (!partialsPaths.length) return cb();
|
||||
var partialPath = partialsPaths.pop();
|
||||
var partial = fs.createReadStream(partialPath);
|
||||
streamToStr(partial, function onDone (str) {
|
||||
partials[getPartialName(partialPath)] = str;
|
||||
readPartials(cb);
|
||||
});
|
||||
}
|
||||
|
||||
function readTemplate (cb) {
|
||||
var template = fs.createReadStream(templateArg);
|
||||
streamToStr(template, cb);
|
||||
}
|
||||
|
||||
function render (cb, templateStr, jsonView) {
|
||||
cb(Mustache.render(templateStr, jsonView, partials));
|
||||
}
|
||||
|
||||
function toStdout (cb, str) {
|
||||
if (outputArg) {
|
||||
cb(fs.writeFileSync(outputArg, str));
|
||||
} else {
|
||||
cb(process.stdout.write(str));
|
||||
}
|
||||
}
|
||||
|
||||
function streamToStr (stream, cb) {
|
||||
var data = '';
|
||||
|
||||
stream.on('data', function onData (chunk) {
|
||||
data += chunk;
|
||||
}).once('end', function onEnd () {
|
||||
cb(data.toString());
|
||||
}).on('error', function onError (err) {
|
||||
if (wasNotFound(err)) {
|
||||
console.error('Could not find file:', err.path);
|
||||
} else {
|
||||
console.error('Error while reading file:', err.message);
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
function isStdin (view) {
|
||||
return view === '-';
|
||||
}
|
||||
|
||||
function wasNotFound (err) {
|
||||
return err.code && err.code === 'ENOENT';
|
||||
}
|
||||
|
||||
function hasVersionArg () {
|
||||
return ['--version', '-v'].some(function matchInArgs (opt) {
|
||||
return process.argv.indexOf(opt) > -1;
|
||||
});
|
||||
}
|
||||
|
||||
function getPartialName (filename) {
|
||||
return path.basename(filename, '.mustache');
|
||||
}
|
||||
630
node-red-contrib-xiaomi-ht/node_modules/mustache/mustache.js
generated
vendored
630
node-red-contrib-xiaomi-ht/node_modules/mustache/mustache.js
generated
vendored
@@ -1,630 +0,0 @@
|
||||
/*!
|
||||
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
||||
* http://github.com/janl/mustache.js
|
||||
*/
|
||||
|
||||
/*global define: false Mustache: true*/
|
||||
|
||||
(function defineMustache (global, factory) {
|
||||
if (typeof exports === 'object' && exports && typeof exports.nodeName !== 'string') {
|
||||
factory(exports); // CommonJS
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
define(['exports'], factory); // AMD
|
||||
} else {
|
||||
global.Mustache = {};
|
||||
factory(global.Mustache); // script, wsh, asp
|
||||
}
|
||||
}(this, function mustacheFactory (mustache) {
|
||||
|
||||
var objectToString = Object.prototype.toString;
|
||||
var isArray = Array.isArray || function isArrayPolyfill (object) {
|
||||
return objectToString.call(object) === '[object Array]';
|
||||
};
|
||||
|
||||
function isFunction (object) {
|
||||
return typeof object === 'function';
|
||||
}
|
||||
|
||||
/**
|
||||
* More correct typeof string handling array
|
||||
* which normally returns typeof 'object'
|
||||
*/
|
||||
function typeStr (obj) {
|
||||
return isArray(obj) ? 'array' : typeof obj;
|
||||
}
|
||||
|
||||
function escapeRegExp (string) {
|
||||
return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
|
||||
}
|
||||
|
||||
/**
|
||||
* Null safe way of checking whether or not an object,
|
||||
* including its prototype, has a given property
|
||||
*/
|
||||
function hasProperty (obj, propName) {
|
||||
return obj != null && typeof obj === 'object' && (propName in obj);
|
||||
}
|
||||
|
||||
// Workaround for https://issues.apache.org/jira/browse/COUCHDB-577
|
||||
// See https://github.com/janl/mustache.js/issues/189
|
||||
var regExpTest = RegExp.prototype.test;
|
||||
function testRegExp (re, string) {
|
||||
return regExpTest.call(re, string);
|
||||
}
|
||||
|
||||
var nonSpaceRe = /\S/;
|
||||
function isWhitespace (string) {
|
||||
return !testRegExp(nonSpaceRe, string);
|
||||
}
|
||||
|
||||
var entityMap = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
'/': '/',
|
||||
'`': '`',
|
||||
'=': '='
|
||||
};
|
||||
|
||||
function escapeHtml (string) {
|
||||
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
|
||||
return entityMap[s];
|
||||
});
|
||||
}
|
||||
|
||||
var whiteRe = /\s*/;
|
||||
var spaceRe = /\s+/;
|
||||
var equalsRe = /\s*=/;
|
||||
var curlyRe = /\s*\}/;
|
||||
var tagRe = /#|\^|\/|>|\{|&|=|!/;
|
||||
|
||||
/**
|
||||
* Breaks up the given `template` string into a tree of tokens. If the `tags`
|
||||
* argument is given here it must be an array with two string values: the
|
||||
* opening and closing tags used in the template (e.g. [ "<%", "%>" ]). Of
|
||||
* course, the default is to use mustaches (i.e. mustache.tags).
|
||||
*
|
||||
* A token is an array with at least 4 elements. The first element is the
|
||||
* mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag
|
||||
* did not contain a symbol (i.e. {{myValue}}) this element is "name". For
|
||||
* all text that appears outside a symbol this element is "text".
|
||||
*
|
||||
* The second element of a token is its "value". For mustache tags this is
|
||||
* whatever else was inside the tag besides the opening symbol. For text tokens
|
||||
* this is the text itself.
|
||||
*
|
||||
* The third and fourth elements of the token are the start and end indices,
|
||||
* respectively, of the token in the original template.
|
||||
*
|
||||
* Tokens that are the root node of a subtree contain two more elements: 1) an
|
||||
* array of tokens in the subtree and 2) the index in the original template at
|
||||
* which the closing tag for that section begins.
|
||||
*/
|
||||
function parseTemplate (template, tags) {
|
||||
if (!template)
|
||||
return [];
|
||||
|
||||
var sections = []; // Stack to hold section tokens
|
||||
var tokens = []; // Buffer to hold the tokens
|
||||
var spaces = []; // Indices of whitespace tokens on the current line
|
||||
var hasTag = false; // Is there a {{tag}} on the current line?
|
||||
var nonSpace = false; // Is there a non-space char on the current line?
|
||||
|
||||
// Strips all whitespace tokens array for the current line
|
||||
// if there was a {{#tag}} on it and otherwise only space.
|
||||
function stripSpace () {
|
||||
if (hasTag && !nonSpace) {
|
||||
while (spaces.length)
|
||||
delete tokens[spaces.pop()];
|
||||
} else {
|
||||
spaces = [];
|
||||
}
|
||||
|
||||
hasTag = false;
|
||||
nonSpace = false;
|
||||
}
|
||||
|
||||
var openingTagRe, closingTagRe, closingCurlyRe;
|
||||
function compileTags (tagsToCompile) {
|
||||
if (typeof tagsToCompile === 'string')
|
||||
tagsToCompile = tagsToCompile.split(spaceRe, 2);
|
||||
|
||||
if (!isArray(tagsToCompile) || tagsToCompile.length !== 2)
|
||||
throw new Error('Invalid tags: ' + tagsToCompile);
|
||||
|
||||
openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + '\\s*');
|
||||
closingTagRe = new RegExp('\\s*' + escapeRegExp(tagsToCompile[1]));
|
||||
closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tagsToCompile[1]));
|
||||
}
|
||||
|
||||
compileTags(tags || mustache.tags);
|
||||
|
||||
var scanner = new Scanner(template);
|
||||
|
||||
var start, type, value, chr, token, openSection;
|
||||
while (!scanner.eos()) {
|
||||
start = scanner.pos;
|
||||
|
||||
// Match any text between tags.
|
||||
value = scanner.scanUntil(openingTagRe);
|
||||
|
||||
if (value) {
|
||||
for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
|
||||
chr = value.charAt(i);
|
||||
|
||||
if (isWhitespace(chr)) {
|
||||
spaces.push(tokens.length);
|
||||
} else {
|
||||
nonSpace = true;
|
||||
}
|
||||
|
||||
tokens.push([ 'text', chr, start, start + 1 ]);
|
||||
start += 1;
|
||||
|
||||
// Check for whitespace on the current line.
|
||||
if (chr === '\n')
|
||||
stripSpace();
|
||||
}
|
||||
}
|
||||
|
||||
// Match the opening tag.
|
||||
if (!scanner.scan(openingTagRe))
|
||||
break;
|
||||
|
||||
hasTag = true;
|
||||
|
||||
// Get the tag type.
|
||||
type = scanner.scan(tagRe) || 'name';
|
||||
scanner.scan(whiteRe);
|
||||
|
||||
// Get the tag value.
|
||||
if (type === '=') {
|
||||
value = scanner.scanUntil(equalsRe);
|
||||
scanner.scan(equalsRe);
|
||||
scanner.scanUntil(closingTagRe);
|
||||
} else if (type === '{') {
|
||||
value = scanner.scanUntil(closingCurlyRe);
|
||||
scanner.scan(curlyRe);
|
||||
scanner.scanUntil(closingTagRe);
|
||||
type = '&';
|
||||
} else {
|
||||
value = scanner.scanUntil(closingTagRe);
|
||||
}
|
||||
|
||||
// Match the closing tag.
|
||||
if (!scanner.scan(closingTagRe))
|
||||
throw new Error('Unclosed tag at ' + scanner.pos);
|
||||
|
||||
token = [ type, value, start, scanner.pos ];
|
||||
tokens.push(token);
|
||||
|
||||
if (type === '#' || type === '^') {
|
||||
sections.push(token);
|
||||
} else if (type === '/') {
|
||||
// Check section nesting.
|
||||
openSection = sections.pop();
|
||||
|
||||
if (!openSection)
|
||||
throw new Error('Unopened section "' + value + '" at ' + start);
|
||||
|
||||
if (openSection[1] !== value)
|
||||
throw new Error('Unclosed section "' + openSection[1] + '" at ' + start);
|
||||
} else if (type === 'name' || type === '{' || type === '&') {
|
||||
nonSpace = true;
|
||||
} else if (type === '=') {
|
||||
// Set the tags for the next time around.
|
||||
compileTags(value);
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure there are no open sections when we're done.
|
||||
openSection = sections.pop();
|
||||
|
||||
if (openSection)
|
||||
throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos);
|
||||
|
||||
return nestTokens(squashTokens(tokens));
|
||||
}
|
||||
|
||||
/**
|
||||
* Combines the values of consecutive text tokens in the given `tokens` array
|
||||
* to a single token.
|
||||
*/
|
||||
function squashTokens (tokens) {
|
||||
var squashedTokens = [];
|
||||
|
||||
var token, lastToken;
|
||||
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
||||
token = tokens[i];
|
||||
|
||||
if (token) {
|
||||
if (token[0] === 'text' && lastToken && lastToken[0] === 'text') {
|
||||
lastToken[1] += token[1];
|
||||
lastToken[3] = token[3];
|
||||
} else {
|
||||
squashedTokens.push(token);
|
||||
lastToken = token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return squashedTokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forms the given array of `tokens` into a nested tree structure where
|
||||
* tokens that represent a section have two additional items: 1) an array of
|
||||
* all tokens that appear in that section and 2) the index in the original
|
||||
* template that represents the end of that section.
|
||||
*/
|
||||
function nestTokens (tokens) {
|
||||
var nestedTokens = [];
|
||||
var collector = nestedTokens;
|
||||
var sections = [];
|
||||
|
||||
var token, section;
|
||||
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
||||
token = tokens[i];
|
||||
|
||||
switch (token[0]) {
|
||||
case '#':
|
||||
case '^':
|
||||
collector.push(token);
|
||||
sections.push(token);
|
||||
collector = token[4] = [];
|
||||
break;
|
||||
case '/':
|
||||
section = sections.pop();
|
||||
section[5] = token[2];
|
||||
collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
|
||||
break;
|
||||
default:
|
||||
collector.push(token);
|
||||
}
|
||||
}
|
||||
|
||||
return nestedTokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple string scanner that is used by the template parser to find
|
||||
* tokens in template strings.
|
||||
*/
|
||||
function Scanner (string) {
|
||||
this.string = string;
|
||||
this.tail = string;
|
||||
this.pos = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the tail is empty (end of string).
|
||||
*/
|
||||
Scanner.prototype.eos = function eos () {
|
||||
return this.tail === '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Tries to match the given regular expression at the current position.
|
||||
* Returns the matched text if it can match, the empty string otherwise.
|
||||
*/
|
||||
Scanner.prototype.scan = function scan (re) {
|
||||
var match = this.tail.match(re);
|
||||
|
||||
if (!match || match.index !== 0)
|
||||
return '';
|
||||
|
||||
var string = match[0];
|
||||
|
||||
this.tail = this.tail.substring(string.length);
|
||||
this.pos += string.length;
|
||||
|
||||
return string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Skips all text until the given regular expression can be matched. Returns
|
||||
* the skipped string, which is the entire tail if no match can be made.
|
||||
*/
|
||||
Scanner.prototype.scanUntil = function scanUntil (re) {
|
||||
var index = this.tail.search(re), match;
|
||||
|
||||
switch (index) {
|
||||
case -1:
|
||||
match = this.tail;
|
||||
this.tail = '';
|
||||
break;
|
||||
case 0:
|
||||
match = '';
|
||||
break;
|
||||
default:
|
||||
match = this.tail.substring(0, index);
|
||||
this.tail = this.tail.substring(index);
|
||||
}
|
||||
|
||||
this.pos += match.length;
|
||||
|
||||
return match;
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a rendering context by wrapping a view object and
|
||||
* maintaining a reference to the parent context.
|
||||
*/
|
||||
function Context (view, parentContext) {
|
||||
this.view = view;
|
||||
this.cache = { '.': this.view };
|
||||
this.parent = parentContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new context using the given view with this context
|
||||
* as the parent.
|
||||
*/
|
||||
Context.prototype.push = function push (view) {
|
||||
return new Context(view, this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the value of the given name in this context, traversing
|
||||
* up the context hierarchy if the value is absent in this context's view.
|
||||
*/
|
||||
Context.prototype.lookup = function lookup (name) {
|
||||
var cache = this.cache;
|
||||
|
||||
var value;
|
||||
if (cache.hasOwnProperty(name)) {
|
||||
value = cache[name];
|
||||
} else {
|
||||
var context = this, names, index, lookupHit = false;
|
||||
|
||||
while (context) {
|
||||
if (name.indexOf('.') > 0) {
|
||||
value = context.view;
|
||||
names = name.split('.');
|
||||
index = 0;
|
||||
|
||||
/**
|
||||
* Using the dot notion path in `name`, we descend through the
|
||||
* nested objects.
|
||||
*
|
||||
* To be certain that the lookup has been successful, we have to
|
||||
* check if the last object in the path actually has the property
|
||||
* we are looking for. We store the result in `lookupHit`.
|
||||
*
|
||||
* This is specially necessary for when the value has been set to
|
||||
* `undefined` and we want to avoid looking up parent contexts.
|
||||
**/
|
||||
while (value != null && index < names.length) {
|
||||
if (index === names.length - 1)
|
||||
lookupHit = hasProperty(value, names[index]);
|
||||
|
||||
value = value[names[index++]];
|
||||
}
|
||||
} else {
|
||||
value = context.view[name];
|
||||
lookupHit = hasProperty(context.view, name);
|
||||
}
|
||||
|
||||
if (lookupHit)
|
||||
break;
|
||||
|
||||
context = context.parent;
|
||||
}
|
||||
|
||||
cache[name] = value;
|
||||
}
|
||||
|
||||
if (isFunction(value))
|
||||
value = value.call(this.view);
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* A Writer knows how to take a stream of tokens and render them to a
|
||||
* string, given a context. It also maintains a cache of templates to
|
||||
* avoid the need to parse the same template twice.
|
||||
*/
|
||||
function Writer () {
|
||||
this.cache = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all cached templates in this writer.
|
||||
*/
|
||||
Writer.prototype.clearCache = function clearCache () {
|
||||
this.cache = {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses and caches the given `template` and returns the array of tokens
|
||||
* that is generated from the parse.
|
||||
*/
|
||||
Writer.prototype.parse = function parse (template, tags) {
|
||||
var cache = this.cache;
|
||||
var tokens = cache[template];
|
||||
|
||||
if (tokens == null)
|
||||
tokens = cache[template] = parseTemplate(template, tags);
|
||||
|
||||
return tokens;
|
||||
};
|
||||
|
||||
/**
|
||||
* High-level method that is used to render the given `template` with
|
||||
* the given `view`.
|
||||
*
|
||||
* The optional `partials` argument may be an object that contains the
|
||||
* names and templates of partials that are used in the template. It may
|
||||
* also be a function that is used to load partial templates on the fly
|
||||
* that takes a single argument: the name of the partial.
|
||||
*/
|
||||
Writer.prototype.render = function render (template, view, partials) {
|
||||
var tokens = this.parse(template);
|
||||
var context = (view instanceof Context) ? view : new Context(view);
|
||||
return this.renderTokens(tokens, context, partials, template);
|
||||
};
|
||||
|
||||
/**
|
||||
* Low-level method that renders the given array of `tokens` using
|
||||
* the given `context` and `partials`.
|
||||
*
|
||||
* Note: The `originalTemplate` is only ever used to extract the portion
|
||||
* of the original template that was contained in a higher-order section.
|
||||
* If the template doesn't use higher-order sections, this argument may
|
||||
* be omitted.
|
||||
*/
|
||||
Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate) {
|
||||
var buffer = '';
|
||||
|
||||
var token, symbol, value;
|
||||
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
||||
value = undefined;
|
||||
token = tokens[i];
|
||||
symbol = token[0];
|
||||
|
||||
if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate);
|
||||
else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate);
|
||||
else if (symbol === '>') value = this.renderPartial(token, context, partials, originalTemplate);
|
||||
else if (symbol === '&') value = this.unescapedValue(token, context);
|
||||
else if (symbol === 'name') value = this.escapedValue(token, context);
|
||||
else if (symbol === 'text') value = this.rawValue(token);
|
||||
|
||||
if (value !== undefined)
|
||||
buffer += value;
|
||||
}
|
||||
|
||||
return buffer;
|
||||
};
|
||||
|
||||
Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate) {
|
||||
var self = this;
|
||||
var buffer = '';
|
||||
var value = context.lookup(token[1]);
|
||||
|
||||
// This function is used to render an arbitrary template
|
||||
// in the current context by higher-order sections.
|
||||
function subRender (template) {
|
||||
return self.render(template, context, partials);
|
||||
}
|
||||
|
||||
if (!value) return;
|
||||
|
||||
if (isArray(value)) {
|
||||
for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
|
||||
buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate);
|
||||
}
|
||||
} else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') {
|
||||
buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate);
|
||||
} else if (isFunction(value)) {
|
||||
if (typeof originalTemplate !== 'string')
|
||||
throw new Error('Cannot use higher-order sections without the original template');
|
||||
|
||||
// Extract the portion of the original template that the section contains.
|
||||
value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
|
||||
|
||||
if (value != null)
|
||||
buffer += value;
|
||||
} else {
|
||||
buffer += this.renderTokens(token[4], context, partials, originalTemplate);
|
||||
}
|
||||
return buffer;
|
||||
};
|
||||
|
||||
Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate) {
|
||||
var value = context.lookup(token[1]);
|
||||
|
||||
// Use JavaScript's definition of falsy. Include empty arrays.
|
||||
// See https://github.com/janl/mustache.js/issues/186
|
||||
if (!value || (isArray(value) && value.length === 0))
|
||||
return this.renderTokens(token[4], context, partials, originalTemplate);
|
||||
};
|
||||
|
||||
Writer.prototype.renderPartial = function renderPartial (token, context, partials) {
|
||||
if (!partials) return;
|
||||
|
||||
var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
|
||||
if (value != null)
|
||||
return this.renderTokens(this.parse(value), context, partials, value);
|
||||
};
|
||||
|
||||
Writer.prototype.unescapedValue = function unescapedValue (token, context) {
|
||||
var value = context.lookup(token[1]);
|
||||
if (value != null)
|
||||
return value;
|
||||
};
|
||||
|
||||
Writer.prototype.escapedValue = function escapedValue (token, context) {
|
||||
var value = context.lookup(token[1]);
|
||||
if (value != null)
|
||||
return mustache.escape(value);
|
||||
};
|
||||
|
||||
Writer.prototype.rawValue = function rawValue (token) {
|
||||
return token[1];
|
||||
};
|
||||
|
||||
mustache.name = 'mustache.js';
|
||||
mustache.version = '2.3.0';
|
||||
mustache.tags = [ '{{', '}}' ];
|
||||
|
||||
// All high-level mustache.* functions use this writer.
|
||||
var defaultWriter = new Writer();
|
||||
|
||||
/**
|
||||
* Clears all cached templates in the default writer.
|
||||
*/
|
||||
mustache.clearCache = function clearCache () {
|
||||
return defaultWriter.clearCache();
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses and caches the given template in the default writer and returns the
|
||||
* array of tokens it contains. Doing this ahead of time avoids the need to
|
||||
* parse templates on the fly as they are rendered.
|
||||
*/
|
||||
mustache.parse = function parse (template, tags) {
|
||||
return defaultWriter.parse(template, tags);
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders the `template` with the given `view` and `partials` using the
|
||||
* default writer.
|
||||
*/
|
||||
mustache.render = function render (template, view, partials) {
|
||||
if (typeof template !== 'string') {
|
||||
throw new TypeError('Invalid template! Template should be a "string" ' +
|
||||
'but "' + typeStr(template) + '" was given as the first ' +
|
||||
'argument for mustache#render(template, view, partials)');
|
||||
}
|
||||
|
||||
return defaultWriter.render(template, view, partials);
|
||||
};
|
||||
|
||||
// This is here for backwards compatibility with 0.4.x.,
|
||||
/*eslint-disable */ // eslint wants camel cased function name
|
||||
mustache.to_html = function to_html (template, view, partials, send) {
|
||||
/*eslint-enable*/
|
||||
|
||||
var result = mustache.render(template, view, partials);
|
||||
|
||||
if (isFunction(send)) {
|
||||
send(result);
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
// Export the escaping function so that the user may override it.
|
||||
// See https://github.com/janl/mustache.js/issues/244
|
||||
mustache.escape = escapeHtml;
|
||||
|
||||
// Export these mainly for testing, but also for advanced usage.
|
||||
mustache.Scanner = Scanner;
|
||||
mustache.Context = Context;
|
||||
mustache.Writer = Writer;
|
||||
|
||||
return mustache;
|
||||
}));
|
||||
1
node-red-contrib-xiaomi-ht/node_modules/mustache/mustache.min.js
generated
vendored
1
node-red-contrib-xiaomi-ht/node_modules/mustache/mustache.min.js
generated
vendored
File diff suppressed because one or more lines are too long
144
node-red-contrib-xiaomi-ht/node_modules/mustache/package.json
generated
vendored
144
node-red-contrib-xiaomi-ht/node_modules/mustache/package.json
generated
vendored
@@ -1,144 +0,0 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "mustache",
|
||||
"scope": null,
|
||||
"escapedName": "mustache",
|
||||
"name": "mustache",
|
||||
"rawSpec": "",
|
||||
"spec": "latest",
|
||||
"type": "tag"
|
||||
},
|
||||
"/Development/codecentric/node-red/node-red-contrib-xiaomi-ht"
|
||||
]
|
||||
],
|
||||
"_from": "mustache@latest",
|
||||
"_id": "mustache@2.3.0",
|
||||
"_inCache": true,
|
||||
"_location": "/mustache",
|
||||
"_nodeVersion": "7.0.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-18-east.internal.npmjs.com",
|
||||
"tmp": "tmp/mustache-2.3.0.tgz_1478622318106_0.5297125231008977"
|
||||
},
|
||||
"_npmUser": {
|
||||
"name": "dasilvacontin",
|
||||
"email": "dasilvacontin@gmail.com"
|
||||
},
|
||||
"_npmVersion": "3.10.8",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "mustache",
|
||||
"scope": null,
|
||||
"escapedName": "mustache",
|
||||
"name": "mustache",
|
||||
"rawSpec": "",
|
||||
"spec": "latest",
|
||||
"type": "tag"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER"
|
||||
],
|
||||
"_resolved": "https://nexus3.hamis.nl/repository/npm-all/mustache/-/mustache-2.3.0.tgz",
|
||||
"_shasum": "4028f7778b17708a489930a6e52ac3bca0da41d0",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "mustache",
|
||||
"_where": "/Development/codecentric/node-red/node-red-contrib-xiaomi-ht",
|
||||
"author": {
|
||||
"name": "mustache.js Authors",
|
||||
"email": "http://github.com/janl/mustache.js"
|
||||
},
|
||||
"bin": {
|
||||
"mustache": "./bin/mustache"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/janl/mustache.js/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Logic-less {{mustache}} templates with JavaScript",
|
||||
"devDependencies": {
|
||||
"chai": "^3.4.0",
|
||||
"eslint": "^2.5.1",
|
||||
"mocha": "^3.0.2",
|
||||
"zuul": "^3.11.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "4028f7778b17708a489930a6e52ac3bca0da41d0",
|
||||
"tarball": "https://nexus3.hamis.nl/repository/npm-all/mustache/-/mustache-2.3.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"npm": ">=1.4.0"
|
||||
},
|
||||
"files": [
|
||||
"mustache.js",
|
||||
"mustache.min.js",
|
||||
"bin",
|
||||
"wrappers",
|
||||
"LICENSE"
|
||||
],
|
||||
"gitHead": "23beb3a8805c9a857e3ea777431481599fab503e",
|
||||
"greenkeeper": {
|
||||
"ignore": [
|
||||
"eslint"
|
||||
]
|
||||
},
|
||||
"homepage": "https://github.com/janl/mustache.js",
|
||||
"keywords": [
|
||||
"mustache",
|
||||
"template",
|
||||
"templates",
|
||||
"ejs"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./mustache.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "dasilvacontin",
|
||||
"email": "dasilvacontin@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "flipp",
|
||||
"email": "johphi@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "jan",
|
||||
"email": "jan@apache.org"
|
||||
},
|
||||
{
|
||||
"name": "mjackson",
|
||||
"email": "mjijackson@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "nathan",
|
||||
"email": "nrstott@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "mustache",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/janl/mustache.js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"pre-test-browser": "node test/create-browser-suite.js",
|
||||
"pretest": "eslint mustache.js bin/mustache",
|
||||
"test": "mocha --reporter spec test/*-test.js",
|
||||
"test-browser": "npm run pre-test-browser && zuul -- test/context-test.js test/parse-test.js test/scanner-test.js test/render-test-browser.js",
|
||||
"test-browser-local": "npm run pre-test-browser && zuul --local 8080 -- test/context-test.js test/scanner-test.js test/parse-test.js test/render-test-browser.js",
|
||||
"test-render": "mocha --reporter spec test/render-test"
|
||||
},
|
||||
"spm": {
|
||||
"main": "mustache.js",
|
||||
"ignore": [
|
||||
"test",
|
||||
"wrappers"
|
||||
]
|
||||
},
|
||||
"version": "2.3.0",
|
||||
"volo": {
|
||||
"url": "https://raw.github.com/janl/mustache.js/{version}/mustache.js"
|
||||
}
|
||||
}
|
||||
4
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/dojo/mustache.js.post
generated
vendored
4
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/dojo/mustache.js.post
generated
vendored
@@ -1,4 +0,0 @@
|
||||
|
||||
dojox.mustache = dojo.hitch(Mustache, "render");
|
||||
|
||||
})();
|
||||
9
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/dojo/mustache.js.pre
generated
vendored
9
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/dojo/mustache.js.pre
generated
vendored
@@ -1,9 +0,0 @@
|
||||
/*
|
||||
Shameless port of a shameless port
|
||||
@defunkt => @janl => @aq => @voodootikigod
|
||||
|
||||
See http://github.com/defunkt/mustache for more info.
|
||||
*/
|
||||
|
||||
dojo.provide("dojox.mustache._base");
|
||||
(function(){
|
||||
13
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/jquery/mustache.js.post
generated
vendored
13
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/jquery/mustache.js.post
generated
vendored
@@ -1,13 +0,0 @@
|
||||
$.mustache = function (template, view, partials) {
|
||||
return Mustache.render(template, view, partials);
|
||||
};
|
||||
|
||||
$.fn.mustache = function (view, partials) {
|
||||
return $(this).map(function (i, elm) {
|
||||
var template = $.trim($(elm).html());
|
||||
var output = $.mustache(template, view, partials);
|
||||
return $(output).get();
|
||||
});
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
9
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/jquery/mustache.js.pre
generated
vendored
9
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/jquery/mustache.js.pre
generated
vendored
@@ -1,9 +0,0 @@
|
||||
/*
|
||||
Shameless port of a shameless port
|
||||
@defunkt => @janl => @aq
|
||||
|
||||
See http://github.com/defunkt/mustache for more info.
|
||||
*/
|
||||
|
||||
;(function($) {
|
||||
|
||||
5
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/mootools/mustache.js.post
generated
vendored
5
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/mootools/mustache.js.post
generated
vendored
@@ -1,5 +0,0 @@
|
||||
|
||||
Object.implement('mustache', function(view, partials){
|
||||
return Mustache.render(view, this, partials);
|
||||
});
|
||||
})();
|
||||
2
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/mootools/mustache.js.pre
generated
vendored
2
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/mootools/mustache.js.pre
generated
vendored
@@ -1,2 +0,0 @@
|
||||
(function(){
|
||||
|
||||
9
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/qooxdoo/mustache.js.post
generated
vendored
9
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/qooxdoo/mustache.js.post
generated
vendored
@@ -1,9 +0,0 @@
|
||||
/**
|
||||
* Above is the original mustache code.
|
||||
*/
|
||||
|
||||
// EXPOSE qooxdoo variant
|
||||
qx.bom.Template.version = this.Mustache.version;
|
||||
qx.bom.Template.render = this.Mustache.render;
|
||||
|
||||
}).call({});
|
||||
172
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/qooxdoo/mustache.js.pre
generated
vendored
172
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/qooxdoo/mustache.js.pre
generated
vendored
@@ -1,172 +0,0 @@
|
||||
/* ************************************************************************
|
||||
|
||||
qooxdoo - the new era of web development
|
||||
|
||||
http://qooxdoo.org
|
||||
|
||||
Copyright:
|
||||
2004-2012 1&1 Internet AG, Germany, http://www.1und1.de
|
||||
|
||||
License:
|
||||
LGPL: http://www.gnu.org/licenses/lgpl.html
|
||||
EPL: http://www.eclipse.org/org/documents/epl-v10.php
|
||||
See the LICENSE file in the project's top-level directory for details.
|
||||
|
||||
Authors:
|
||||
* Martin Wittemann (martinwittemann)
|
||||
|
||||
======================================================================
|
||||
|
||||
This class contains code based on the following work:
|
||||
|
||||
* Mustache.js version 0.8.0
|
||||
|
||||
Code:
|
||||
https://github.com/janl/mustache.js
|
||||
|
||||
Copyright:
|
||||
(c) 2009 Chris Wanstrath (Ruby)
|
||||
(c) 2010 Jan Lehnardt (JavaScript)
|
||||
|
||||
License:
|
||||
MIT: http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2009 Chris Wanstrath (Ruby)
|
||||
Copyright (c) 2010 Jan Lehnardt (JavaScript)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
************************************************************************ */
|
||||
|
||||
/**
|
||||
* The is a template class which can be used for HTML templating. In fact,
|
||||
* this is a wrapper for mustache.js which is a "framework-agnostic way to
|
||||
* render logic-free views".
|
||||
*
|
||||
* Here is a basic example how to use it:
|
||||
* Template:
|
||||
* <pre class="javascript">
|
||||
* var template = "Hi, my name is {{name}}!";
|
||||
* var view = {name: "qooxdoo"};
|
||||
* qx.bom.Template.render(template, view);
|
||||
* // return "Hi, my name is qooxdoo!"
|
||||
* </pre>
|
||||
*
|
||||
* For further details, please visit the mustache.js documentation here:
|
||||
* https://github.com/janl/mustache.js/blob/master/README.md
|
||||
*
|
||||
* @ignore(module)
|
||||
*/
|
||||
qx.Bootstrap.define("qx.bom.Template", {
|
||||
statics : {
|
||||
/** Contains the mustache.js version. */
|
||||
version: null,
|
||||
|
||||
/**
|
||||
* Original and only template method of mustache.js. For further
|
||||
* documentation, please visit https://github.com/janl/mustache.js
|
||||
*
|
||||
* @signature function(template, view, partials)
|
||||
* @param template {String} The String containing the template.
|
||||
* @param view {Object} The object holding the data to render.
|
||||
* @param partials {Object} Object holding parts of a template.
|
||||
* @return {String} The parsed template.
|
||||
*/
|
||||
render: null,
|
||||
|
||||
/**
|
||||
* Combines {@link #render} and {@link #get}. Input is equal to {@link #render}
|
||||
* and output is equal to {@link #get}. The advantage over {@link #get}
|
||||
* is that you don't need a HTML template but can use a template
|
||||
* string and still get a DOM element. Keep in mind that templates
|
||||
* can only have one root element.
|
||||
*
|
||||
* @param template {String} The String containing the template.
|
||||
* @param view {Object} The object holding the data to render.
|
||||
* @param partials {Object} Object holding parts of a template.
|
||||
* @return {Element} A DOM element holding the parsed template data.
|
||||
*/
|
||||
renderToNode : function(template, view, partials) {
|
||||
var renderedTmpl = this.render(template, view, partials);
|
||||
return this._createNodeFromTemplate(renderedTmpl);
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper method which provides you with a direct access to templates
|
||||
* stored as HTML in the DOM. The DOM node with the given ID will be used
|
||||
* as a template, parsed and a new DOM node will be returned containing the
|
||||
* parsed data. Keep in mind to have only one root DOM element in the the
|
||||
* template.
|
||||
* Additionally, you should not put the template into a regular, hidden
|
||||
* DOM element because the template may not be valid HTML due to the containing
|
||||
* mustache tags. We suggest to put it into a script tag with the type
|
||||
* <code>text/template</code>.
|
||||
*
|
||||
* @param id {String} The id of the HTML template in the DOM.
|
||||
* @param view {Object} The object holding the data to render.
|
||||
* @param partials {Object} Object holding parts of a template.
|
||||
* @return {Element} A DOM element holding the parsed template data.
|
||||
*/
|
||||
get : function(id, view, partials) {
|
||||
// get the content stored in the DOM
|
||||
var template = document.getElementById(id);
|
||||
return this.renderToNode(template.innerHTML, view, partials);
|
||||
},
|
||||
|
||||
/**
|
||||
* Accepts a parsed template and returns a (potentially nested) node.
|
||||
*
|
||||
* @param template {String} The String containing the template.
|
||||
* @return {Element} A DOM element holding the parsed template data.
|
||||
*/
|
||||
_createNodeFromTemplate : function(template) {
|
||||
// template is text only (no html elems) so use text node
|
||||
if (template.search(/<|>/) === -1) {
|
||||
return document.createTextNode(template);
|
||||
}
|
||||
|
||||
// template has html elems so convert string into DOM nodes
|
||||
var helper = qx.dom.Element.create("div");
|
||||
helper.innerHTML = template;
|
||||
|
||||
return helper.children[0];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
// prevent using CommonJS exports object,
|
||||
// by shadowing global exports object
|
||||
var exports;
|
||||
|
||||
// prevent using AMD compatible loader,
|
||||
// by shadowing global define function
|
||||
var define;
|
||||
|
||||
/**
|
||||
* Below is the original mustache.js code. Snapshot date is mentioned in
|
||||
* the head of this file.
|
||||
* @ignore(exports)
|
||||
* @ignore(define.*)
|
||||
* @ignore(module.*)
|
||||
* @lint ignoreNoLoopBlock()
|
||||
*/
|
||||
4
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/yui3/mustache.js.post
generated
vendored
4
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/yui3/mustache.js.post
generated
vendored
@@ -1,4 +0,0 @@
|
||||
|
||||
Y.mustache = Mustache.render;
|
||||
|
||||
}, "0");
|
||||
1
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/yui3/mustache.js.pre
generated
vendored
1
node-red-contrib-xiaomi-ht/node_modules/mustache/wrappers/yui3/mustache.js.pre
generated
vendored
@@ -1 +0,0 @@
|
||||
YUI.add("mustache", function(Y) {
|
||||
@@ -42,7 +42,9 @@
|
||||
|
||||
for (key in configNode.deviceList) {
|
||||
var device = configNode.deviceList[key];
|
||||
$('#node-input-sid').append('<option value="' + device.sid + '">' + device.desc + '</option>');
|
||||
if (device.model === "sensor_ht") {
|
||||
$('#node-input-sid').append('<option value="' + device.sid + '">' + device.desc + '</option>');
|
||||
}
|
||||
}
|
||||
$('#node-input-sid').val(node.sid);
|
||||
},
|
||||
|
||||
@@ -16,5 +16,8 @@
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/h-rietman/xiaomi-devices-node-red/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/h-rietman/xiaomi-devices-node-red#README"
|
||||
"homepage": "https://gitlab.com/h-rietman/xiaomi-devices-node-red#README",
|
||||
"dependencies": {
|
||||
"mustache": "^2.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user