Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove i18n

  • Loading branch information...
commit 46781def51e2c28df7e55f98b85f2197b1217df9 1 parent 50e8439
@shaunlee authored
Showing with 6 additions and 49 deletions.
  1. +0 −7 Readme.md
  2. +2 −33 jst.js
  3. +3 −8 lib/jst.js
  4. +1 −1  package.json
View
7 Readme.md
@@ -15,7 +15,6 @@ via npm:
* Unbuffered code for embed codes etc `{% code %}` or `{{ variable }}`
* Enforcing coding standard, for example `{{ variable }}` is correct, but `{{variable}}` is wrong
* Customizable filters
- * Internationalization
## Example
@@ -57,12 +56,6 @@ via npm:
jst.addFilter('filterName', function(arg1, arg2, arg3) { return function(src) { ... }});
jst.render('{{ it.value|filterName(1, 2, 3) }}', {value: 123});
- // i18n
- jst.configure({
- locales: {lang: 'zh_CN', locales: __dirname + '/locales'}
- });
- jst.render('{{ _("Hello {it.name}")|e }}', {name: '<strong>jst</strong>'});
-
// Client side
<script src="jst.js"></script>
<script>
View
35 jst.js
@@ -39,37 +39,6 @@ exports.add = function(value) {
})(filters);
-// i18n
-
-var i18n = {};
-
-;(function(exports) {
-
-/**
- * gettext('Hello {name}', {name: 'jst'})
- */
-exports.gettext = function(ctx, args) {
- // TODO:
-
- for (var name in args) {
- var re = RegExp('\\{' + name + '\\}', 'g');
- ctx = ctx.replace(re, args[name]);
- }
- return ctx;
-}
-
-/**
- * ngettext('There is a template', 'There are {n} templates', n)
- */
-exports.ngettext = function(singular, plural, n) {
- var ctx = n === 1 ? singular : plural;
-
- // TODO:
-
- return ctx.replace(/\{n\}/g, n);
-}
-})(i18n);
-
// compiler
var jst = {};
@@ -142,10 +111,10 @@ var compile = exports.compile = function(ctx) {
code += 'return out;';
//console.log(code);
- var fn = new Function('it, _, _n, filters', code);
+ var fn = new Function('it, filters', code);
return function(args) {
- return fn.call(this, args, i18n.gettext, i18n.ngettext, filters);
+ return fn.call(this, args, filters);
}
}
View
11 lib/jst.js
@@ -5,13 +5,10 @@
*/
var fs = require('fs'),
- locales = require('locales');
filters = require('./filters'),
hash = require('./hash');
-exports.version = '0.0.11';
-
-exports.detector = locales.detector;
+exports.version = '0.0.13';
var _cache = {},
_files = {},
@@ -22,8 +19,6 @@ var _cache = {},
exports.configure = function(options) {
for (var prop in options) {
_options[prop] = options[prop];
- if (prop === 'locales')
- locales.configure(options[prop]);
}
}
@@ -90,10 +85,10 @@ var compile = exports.compile = function(ctx) {
code += 'return out;';
//console.log(code);
- var fn = new Function('it, _, _n, filters', code);
+ var fn = new Function('it, filters', code);
return function(args) {
- return fn.call(this, args, locales.gettext, locales.ngettext, filters.filters);
+ return fn.call(this, args, filters.filters);
}
}
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "jst",
"description": "Node JavaScript Template, A pretty high performance template engine",
- "version": "0.0.12",
+ "version": "0.0.13",
"author": "Shaun Li <shonhen@gmail.com>",
"keywords": ["template", "engine", "jst"],
"main": "./lib/jst.js",
Please sign in to comment.
Something went wrong with that request. Please try again.