# EJS
Embedded JavaScript templates
[![Build Status](https://img.shields.io/travis/mde/ejs/master.svg?style=flat)](https://travis-ci.org/mde/ejs)
[![Developing Dependencies](https://img.shields.io/david/dev/mde/ejs.svg?style=flat)](https://david-dm.org/mde/ejs?type=dev)
[![Known Vulnerabilities](https://snyk.io/test/npm/ejs/badge.svg?style=flat-square)](https://snyk.io/test/npm/ejs)
## Installation
```bash
$ npm install ejs
```
## Features
* Control flow with `<% %>`
* Escaped output with `<%= %>` (escape function configurable)
* Unescaped raw output with `<%- %>`
* Newline-trim mode ('newline slurping') with `-%>` ending tag
* Whitespace-trim mode (slurp all whitespace) for control flow with `<%_ _%>`
* Custom delimiters (e.g., use `<? ?>` instead of `<% %>`)
* Includes
* Client-side support
* Static caching of intermediate JavaScript
* Static caching of templates
* Complies with the [Express](http://expressjs.com) view system
## Example
```html
<% if (user) { %>
<h2><%= user.name %></h2>
<% } %>
```
Try EJS online at: https://ionicabizau.github.io/ejs-playground/.
## Usage
```javascript
var template = ejs.compile(str, options);
template(data);
// => Rendered HTML string
ejs.render(str, data, options);
// => Rendered HTML string
ejs.renderFile(filename, data, options, function(err, str){
// str => Rendered HTML string
});
```
It is also possible to use `ejs.render(dataAndOptions);` where you pass
everything in a single object. In that case, you'll end up with local variables
for all the passed options. However, be aware that your code could break if we
add an option with the same name as one of your data object's properties.
Therefore, we do not recommend using this shortcut.
## Options
- `cache` Compiled functions are cached, requires `filename`
- `filename` The name of the file being rendered. Not required if you
are using `renderFile()`. Used by `cache` to key caches, and for includes.
- `root` Set project root for includes with an absolute path (/file.ejs).
- `context` Function execution context
- `compileDebug` When `false` no debug instrumentation is compiled
- `client` When `true`, compiles a function that can be rendered
in the browser without needing to load the EJS Runtime
([ejs.min.js](https://github.com/mde/ejs/releases/latest)).
- `delimiter` Character to use with angle brackets for open/close
- `debug` Output generated function body
- `strict` When set to `true`, generated function is in strict mode
- `_with` Whether or not to use `with() {}` constructs. If `false` then the locals will be stored in the `locals` object. Set to `false` in strict mode.
- `localsName` Name to use for the object storing local variables when not using `with` Defaults to `locals`
- `rmWhitespace` Remove all safe-to-remove whitespace, including leading
and trailing whitespace. It also enables a safer version of `-%>` line
slurping for all scriptlet tags (it does not strip new lines of tags in
the middle of a line).
- `escape` The escaping function used with `<%=` construct. It is
used in rendering and is `.toString()`ed in the generation of client functions. (By default escapes XML).
This project uses [JSDoc](http://usejsdoc.org/). For the full public API
documentation, clone the repository and run `npm run doc`. This will run JSDoc
with the proper options and output the documentation to `out/`. If you want
the both the public & private API docs, run `npm run devdoc` instead.
## Tags
- `<%` 'Scriptlet' tag, for control-flow, no output
- `<%_` 'Whitespace Slurping' Scriptlet tag, strips all whitespace before it
- `<%=` Outputs the value into the template (escaped)
- `<%-` Outputs the unescaped value into the template
- `<%#` Comment tag, no execution, no output
- `<%%` Outputs a literal '<%'
- `%%>` Outputs a literal '%>'
- `%>` Plain ending tag
- `-%>` Trim-mode ('newline slurp') tag, trims following newline
- `_%>` 'Whitespace Slurping' ending tag, removes all whitespace after it
For the full syntax documentation, please see [docs/syntax.md](https://github.com/mde/ejs/blob/master/docs/syntax.md).
## Includes
Includes either have to be an absolute path, or, if not, are assumed as
relative to the template with the `include` call. For example if you are
including `./views/user/show.ejs` from `./views/users.ejs` you would
use `<%- include('user/show') %>`.
You must specify the `filename` option for the template with the `include`
call unless you are using `renderFile()`.
You'll likely want to use the raw output tag (`<%-`) with your include to avoid
double-escaping the HTML output.
```html
<ul>
<% users.forEach(function(user){ %>
<%- include('user/show', {user: user}) %>
<% }); %>
</ul>
```
Includes are inserted at runtime, so you can use variables for the path in the
`include` call (for example `<%- include(somePath) %>`). Variables in your
top-level data object are available to all your includes, but local variables
need to be passed down.
NOTE: Include preprocessor directives (`<% include user/show %>`) are
still supported.
## Custom delimiters
Custom delimiters can be applied on a per-template basis, or globally:
```javascript
var ejs = require('ejs'),
users = ['geddy', 'neil', 'alex'];
// Just one template
ejs.render('<?= users.join(" | "); ?>', {users: users}, {delimiter: '?'});
// => 'geddy | neil | alex'
// Or globally
ejs.delimiter = '$';
ejs.render('<$= users.join(" | "); $>', {users: users});
// => 'geddy | neil | alex'
```
## Caching
EJS ships with a basic in-process cache for caching the intermediate JavaScript
functions used to render templates. It's easy to plug in LRU caching using
Node's `lru-cache` library:
```javascript
var ejs = require('ejs')
, LRU = require('lru-cache');
ejs.cache = LRU(100); // LRU cache with 100-item limit
```
If you want to clear the EJS cache, call `ejs.clearCache`. If you're using the
LRU cache and need a different limit, simple reset `ejs.cache` to a new instance
of the LRU.
## Custom FileLoader
The default file loader is `fs.readFileSync`, if you want to customize it, you can set ejs.fileLoader.
```javascript
var ejs = require('ejs');
var myFileLoad = function (filePath) {
return 'myFileLoad: ' + fs.readFileSync(filePath);
};
ejs.fileLoader = myFileLoad;
```
With this feature, you can preprocess the template before reading it.
## Layouts
EJS does not specifically support blocks, but layouts can be implemented by
including headers and footers, like so:
```html
<%- include('header') -%>
<h1>
Title
</h1>
<p>
My page
</p>
<%- include('footer') -%>
```
## Client-side support
Go to the [Latest Release](https://github.com/mde/ejs/releases/latest), download
`./ejs.js` or `./ejs.min.js`. Alternately, you can compile it yourself by cloning
the repository and running `jake build` (or `$(npm bin)/jake build` if jake is
not installed globally).
Include one of these files on your page, and `ejs` should be available globally.
### Example
```html
<div id="output"></div>
<script src="ejs.min.js"></script>
<script>
var people = ['geddy', 'neil', 'alex'],
html = ejs.render('<%= people.join(", "); %>', {people: people});
// With jQuery:
$('#output').html(html);
// Vanilla JS:
document.getElementById('output').innerHTML = html;
</script>
```
### Caveats
Most of EJS will work as expected; however, there are a few things to note:
1. Obviously, since you do not have access to the filesystem, `ejs.renderFile()` won't work.
2. For the same reason, `include`s do not work unless you use an `IncludeCallback`. Here is an example:
```javascript
var str = "Hello <%= include('file', {person: 'John'}); %>",
fn = ejs.compile(str, {clien
没有合适的资源?快使用搜索试试~ 我知道了~
Android代码-Mapbox地图盒子 Android SDK
共704个文件
xml:273个
png:181个
java:155个
4星 · 超过85%的资源 需积分: 50 9 下载量 63 浏览量
2019-08-06
04:15:42
上传
评论
收藏 22.55MB ZIP 举报
温馨提示
Mapbox Android Demo app This is a public demo of the Mapbox Android SDK that's available now in the Google Play Store. It shows off all the examples found on mapbox.com/android-sdk/examples using the same code. In addition, the app also includes a section called labs which combines the examples to create more complex demos. To get started using Mapbox in your Android application check out the overview page. Steps to adding a new example Feedback and contribution is encouraged in this repo, if
资源推荐
资源详情
资源评论
收起资源包目录
Android代码-Mapbox地图盒子 Android SDK (704个子文件)
gradlew.bat 2KB
config 1KB
contactEmail 15B
contactPhone 0B
contactWebsite 22B
defaultLanguage 5B
activity.junit.ejs 794B
fulldescription 680B
la_hotels.geojson 1.74MB
new-orleans-neighborhoods.geojson 1.33MB
fake_norway_campsites.geojson 1.16MB
marathon_route.geojson 733KB
college_of_tech_lvl_one.geojson 723KB
college_of_tech.geojson 714KB
tech_annex.geojson 422KB
weather_data_per_state_before2006.geojson 185KB
la_attractions.geojson 155KB
white_house_lvl_0.geojson 142KB
white_house_lvl_1.geojson 66KB
boston_charge_stations.geojson 44KB
albuquerque_locations.geojson 32KB
matched_route.geojson 29KB
downtown_san_jose_hole.geojson 27KB
indoor-3d-map.geojson 25KB
trace.geojson 9KB
sf_poi.geojson 8KB
bathymetry-data.geojson 7KB
la_heatmap_styling_points.geojson 6KB
example.geojson 5KB
brussels_station_exits.geojson 4KB
golden_gate_lines.geojson 4KB
poi_places.geojson 2KB
us_west_coast.geojson 1KB
waving_bear.gif 499KB
.gitignore 160B
.gitignore 48B
.gitignore 38B
.gitignore 7B
dependencies.gradle 9KB
build.gradle 6KB
gradle-config.gradle 2KB
build.gradle 2KB
build.gradle 1KB
gradle-dependencies-graph.gradle 1KB
script-git-version.gradle 1KB
build.gradle 596B
checkstyle.gradle 363B
settings.gradle 70B
gradlew 5KB
gradlew 5KB
Jakefile 2KB
gradle-wrapper.jar 52KB
gradle-wrapper.jar 52KB
MainActivity.java 66KB
SymbolLayerMapillaryActivity.java 42KB
MainActivity.java 30KB
RecyclerViewDirectionsActivity.java 16KB
OfflineManagerActivity.java 15KB
IsochroneActivity.java 15KB
ExpressionIntegrationActivity.java 15KB
FingerDrawQueryActivity.java 15KB
InfoWindowSymbolLayerActivity.java 15KB
TurfPhysicalCircleActivity.java 15KB
OfflineMapActivity.java 14KB
LocationComponentCameraOptionsActivity.java 14KB
CalendarIntegrationActivity.java 13KB
MultipleHeatmapStylingActivity.java 13KB
MatrixApiActivity.java 12KB
LocationPickerActivity.java 12KB
QueryFeatureActivity.java 11KB
SatelliteLandSelectActivity.java 11KB
MovingIconWithTrailingLineActivity.java 11KB
IsochroneSeekbarActivity.java 11KB
MarkerFollowingRouteActivity.java 11KB
AnalyticsTracker.java 10KB
OptimizationActivity.java 10KB
TilequeryActivity.java 10KB
SnakingDirectionsRouteActivity.java 9KB
RecyclerViewOnMapActivity.java 9KB
ValueAnimatorIconAnimationActivity.java 9KB
GeocodingActivity.java 9KB
PulsingLayerOpacityColorActivity.java 9KB
SymbolCollisionDetectionActivity.java 9KB
DemoAppHomeScreenAddressWidget.java 9KB
DirectionsActivity.java 9KB
ClickToAddImageActivity.java 9KB
LocationChangeListeningActivity.java 8KB
LineLayerActivity.java 8KB
DashedLineDirectionsPickerActivity.java 8KB
SimpleOfflineMapActivity.java 8KB
IndoorMapActivity.java 8KB
CircleLayerClusteringActivity.java 8KB
SpaceStationLocationActivity.java 7KB
HeatmapActivity.java 7KB
MapMatchingActivity.java 7KB
BuildingOutlineActivity.java 7KB
IconSizeChangeOnClickActivity.java 7KB
LandingActivity.java 7KB
RevealedPolygonHoleOutlineActivity.java 7KB
PlacesPluginActivity.java 7KB
共 704 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
- _冬日的阳光_2020-02-25最近在看Mapbox的接口,刚好这个资源很有用,好好学学怎么弄这个地图。
普通网友
- 粉丝: 484
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 5G模组升级刷模块救砖以及5G模组资料路由器固件
- C183579-123578-c1235789.jpg
- Qt5.14 绘画板 Qt Creator C++项目
- python实现Excel表格合并
- Java实现读取Excel批量发送邮件.zip
- 【java毕业设计】商城后台管理系统源码(springboot+vue+mysql+说明文档).zip
- 【java毕业设计】开发停车位管理系统(调用百度地图API)源码(springboot+vue+mysql+说明文档).zip
- 星耀软件库(升级版).apk.1
- 基于Django后端和Vue前端的多语言购物车项目设计源码
- 基于Python与Vue的浮光在线教育平台源码设计
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功