Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

i18nliner-handlebars

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18nliner-handlebars - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

30

dist/lib/pre_processor.js

@@ -20,2 +20,3 @@ "use strict";

, StringNode = AST.StringNode
, BooleanNode = AST.BooleanNode
, HashNode = AST.HashNode

@@ -100,14 +101,21 @@ , SexprNode = AST.SexprNode

for (i = 0; i < statementsLen; i++) {
statement = statements[i];
if (statement.type !== 'block') continue;
// consume anything inside this first (e.g. if we have nested t blocks)
this.process(statement.program);
if (statement.inverse)
this.process(statement.inverse);
if (statement.mustache.id.string === "t") {
statements[i] = this.transform(statement);
}
statement = this.processStatement(statements[i]);
if (typeof statement !== 'undefined')
statements[i] = statement;
}
},
processStatement: function(statement) {
if (statement.type !== 'block') return;
// consume anything inside this first (e.g. if we have nested t blocks)
this.process(statement.program);
if (statement.inverse)
this.process(statement.inverse);
if (statement.mustache.id.string !== "t") return;
return this.transform(statement);
},
transform: function(node) {

@@ -119,4 +127,6 @@ var parts = this.inferParts(node.program.statements)

node = node.mustache;
if (!node.params.length)
if (!node.params.length) {
node.params.push(this.inferKey(defaultValue));
hash.push(["i18n_inferred_key", new BooleanNode(true)]);
}
node.params.push(new StringNode(defaultValue));

@@ -123,0 +133,0 @@ node.isHelper = 1;

@@ -19,2 +19,3 @@ /* global window */

, StringNode = AST.StringNode
, BooleanNode = AST.BooleanNode
, HashNode = AST.HashNode

@@ -99,14 +100,21 @@ , SexprNode = AST.SexprNode

for (i = 0; i < statementsLen; i++) {
statement = statements[i];
if (statement.type !== 'block') continue;
// consume anything inside this first (e.g. if we have nested t blocks)
this.process(statement.program);
if (statement.inverse)
this.process(statement.inverse);
if (statement.mustache.id.string === "t") {
statements[i] = this.transform(statement);
}
statement = this.processStatement(statements[i]);
if (typeof statement !== 'undefined')
statements[i] = statement;
}
},
processStatement: function(statement) {
if (statement.type !== 'block') return;
// consume anything inside this first (e.g. if we have nested t blocks)
this.process(statement.program);
if (statement.inverse)
this.process(statement.inverse);
if (statement.mustache.id.string !== "t") return;
return this.transform(statement);
},
transform: function(node) {

@@ -118,4 +126,6 @@ var parts = this.inferParts(node.program.statements)

node = node.mustache;
if (!node.params.length)
if (!node.params.length) {
node.params.push(this.inferKey(defaultValue));
hash.push(["i18n_inferred_key", new BooleanNode(true)]);
}
node.params.push(new StringNode(defaultValue));

@@ -122,0 +132,0 @@ node.isHelper = 1;

{
"name": "i18nliner-handlebars",
"description": "handlebars i18n made simple",
"version": "0.0.5",
"version": "0.0.6",
"contributors": [

@@ -26,2 +26,3 @@ {

"grunt-es6-module-transpiler": "~0.6.0",
"i18nliner": "^0.0.11",
"matchdep": "~0.3.0",

@@ -39,4 +40,4 @@ "mocha": "~1.16.2",

"peerDependencies": {
"i18nliner": "0.0.11"
"i18nliner": "^0.0.11"
}
}

@@ -35,3 +35,3 @@ /* global describe, it, before, after */

p('{{#t}}hello world!{{/t}}'),
c('{{t "key" "hello world!"}}')
c('{{t "key" "hello world!" i18n_inferred_key=true}}')
);

@@ -50,3 +50,3 @@ });

p('{{#t}} ohai! lulz\t {{/t}}'),
c('{{t "key" "ohai! lulz"}}')
c('{{t "key" "ohai! lulz" i18n_inferred_key=true}}')
);

@@ -62,3 +62,3 @@ });

c('{{#if foo}}' +
' {{t "key" "Your Name"}}' +
' {{t "key" "Your Name" i18n_inferred_key=true}}' +
' <input>' +

@@ -86,3 +86,3 @@ '{{/if}}')

'{{/t}}'),
c('{{t "key" "*bold*, or even **combos** get wrapper\'d" w0="<b>$1</b>" w1="<a href=\\"#\\"><i><img />$1</i></a>"}}')
c('{{t "key" "*bold*, or even **combos** get wrapper\'d" w0="<b>$1</b>" w1="<a href=\\"#\\"><i><img />$1</i></a>" i18n_inferred_key=true}}')
);

@@ -103,3 +103,3 @@ });

'{{/t}}'),
c('{{t "key" "the wrappers for *these* *tags* are the same" w0="<b>$1</b>"}}')
c('{{t "key" "the wrappers for *these* *tags* are the same" w0="<b>$1</b>" i18n_inferred_key=true}}')
);

@@ -113,3 +113,3 @@ });

'{{/t}}'),
c('{{t "key" "Hello, %{name}" name=name}}')
c('{{t "key" "Hello, %{name}" name=name i18n_inferred_key=true}}')
);

@@ -123,3 +123,3 @@ });

'{{/t}}'),
c('{{t "key" "Hello, %{pig_latin_name}" pig_latin_name=(pig-latin name)}}')
c('{{t "key" "Hello, %{pig_latin_name}" pig_latin_name=(pig-latin name) i18n_inferred_key=true}}')
);

@@ -133,3 +133,3 @@ });

'{{/t}}'),
c('{{t "key" "Go to *your account*" w0=(__i18nliner_concat "<a href=\\"/asdf\\" title=\\"" (__i18nliner_escape name) "\\">$1</a>")}}')
c('{{t "key" "Go to *your account*" w0=(__i18nliner_concat "<a href=\\"/asdf\\" title=\\"" (__i18nliner_escape name) "\\">$1</a>") i18n_inferred_key=true}}')
);

@@ -143,3 +143,3 @@ });

'{{/t}}'),
c('{{t "key" "Go to *your account*" w0=(__i18nliner_concat "<a href=\\"/asdf\\" title=\\"" (__i18nliner_escape (pig-latin name)) "\\">$1</a>")}}')
c('{{t "key" "Go to *your account*" w0=(__i18nliner_concat "<a href=\\"/asdf\\" title=\\"" (__i18nliner_escape (pig-latin name)) "\\">$1</a>") i18n_inferred_key=true}}')
);

@@ -156,3 +156,3 @@ });

'{{/t}}'),
c('{{t "key" "Go to *your account*" w0=(__i18nliner_concat "<a href=\\"/asdf\\" title=\\"" (__i18nliner_escape (t "key" "manage account stuffs, %{name}" name=name)) "\\">$1</a>")}}')
c('{{t "key" "Go to *your account*" w0=(__i18nliner_concat "<a href=\\"/asdf\\" title=\\"" (__i18nliner_escape (t "key" "manage account stuffs, %{name}" name=name i18n_inferred_key=true)) "\\">$1</a>") i18n_inferred_key=true}}')
);

@@ -166,3 +166,3 @@ });

'{{/t}}'),
c('{{t "key" "Create %{input_type_text_name_count} groups" input_type_text_name_count=(__i18nliner_safe "<input type=\\"text\\" name=\\"count\\" />")}}')
c('{{t "key" "Create %{input_type_text_name_count} groups" input_type_text_name_count=(__i18nliner_safe "<input type=\\"text\\" name=\\"count\\" />") i18n_inferred_key=true}}')
);

@@ -176,3 +176,3 @@ });

'{{/t}}'),
c('{{t "key" "© 2014 ACME Corp. All Rights Reserved. Our lawyers > your lawyers"}}')
c('{{t "key" "© 2014 ACME Corp. All Rights Reserved. Our lawyers > your lawyers" i18n_inferred_key=true}}')
);

@@ -179,0 +179,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc