jade-js-source 0.17.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/jade_js/jade.js +77 -12
  2. metadata +3 -5
@@ -714,7 +714,7 @@ var Parser = require('./parser')
714
714
  * Library version.
715
715
  */
716
716
 
717
- exports.version = '0.17.0';
717
+ exports.version = '0.19.0';
718
718
 
719
719
  /**
720
720
  * Expose self closing tags.
@@ -913,12 +913,15 @@ exports.renderFile = function(path, options, fn){
913
913
  fn = options, options = {};
914
914
  }
915
915
 
916
- options.filename = path;
917
- var str = options.cache
918
- ? exports.cache[key] || (exports.cache[key] = fs.readFileSync(path, 'utf8'))
919
- : fs.readFileSync(path, 'utf8');
920
-
921
- exports.render(str, options, fn);
916
+ try {
917
+ options.filename = path;
918
+ var str = options.cache
919
+ ? exports.cache[key] || (exports.cache[key] = fs.readFileSync(path, 'utf8'))
920
+ : fs.readFileSync(path, 'utf8');
921
+ exports.render(str, options, fn);
922
+ } catch (err) {
923
+ fn(err);
924
+ }
922
925
  };
923
926
 
924
927
  /**
@@ -1179,12 +1182,52 @@ Lexer.prototype = {
1179
1182
  return this.scan(/^extends +([^\n]+)/, 'extends');
1180
1183
  },
1181
1184
 
1185
+ /**
1186
+ * Block prepend.
1187
+ */
1188
+
1189
+ prepend: function() {
1190
+ var captures;
1191
+ if (captures = /^prepend +([^\n]+)/.exec(this.input)) {
1192
+ this.consume(captures[0].length);
1193
+ var mode = 'prepend'
1194
+ , name = captures[1]
1195
+ , tok = this.tok('block', name);
1196
+ tok.mode = mode;
1197
+ return tok;
1198
+ }
1199
+ },
1200
+
1201
+ /**
1202
+ * Block append.
1203
+ */
1204
+
1205
+ append: function() {
1206
+ var captures;
1207
+ if (captures = /^append +([^\n]+)/.exec(this.input)) {
1208
+ this.consume(captures[0].length);
1209
+ var mode = 'append'
1210
+ , name = captures[1]
1211
+ , tok = this.tok('block', name);
1212
+ tok.mode = mode;
1213
+ return tok;
1214
+ }
1215
+ },
1216
+
1182
1217
  /**
1183
1218
  * Block.
1184
1219
  */
1185
1220
 
1186
1221
  block: function() {
1187
- return this.scan(/^block +([^\n]+)/, 'block');
1222
+ var captures;
1223
+ if (captures = /^block +(?:(prepend|append) +)?([^\n]+)/.exec(this.input)) {
1224
+ this.consume(captures[0].length);
1225
+ var mode = captures[1] || 'replace'
1226
+ , name = captures[2]
1227
+ , tok = this.tok('block', name);
1228
+ tok.mode = mode;
1229
+ return tok;
1230
+ }
1188
1231
  },
1189
1232
 
1190
1233
  /**
@@ -1566,6 +1609,8 @@ Lexer.prototype = {
1566
1609
  || this.when()
1567
1610
  || this.default()
1568
1611
  || this.extends()
1612
+ || this.append()
1613
+ || this.prepend()
1569
1614
  || this.block()
1570
1615
  || this.include()
1571
1616
  || this.mixin()
@@ -2259,7 +2304,7 @@ var Parser = exports = module.exports = function Parser(str, filename, options){
2259
2304
  * Tags that may not contain tags.
2260
2305
  */
2261
2306
 
2262
- var textOnly = exports.textOnly = ['code', 'script', 'textarea', 'style', 'title'];
2307
+ var textOnly = exports.textOnly = ['script', 'style'];
2263
2308
 
2264
2309
  /**
2265
2310
  * Parser prototype.
@@ -2632,11 +2677,31 @@ Parser.prototype = {
2632
2677
  */
2633
2678
 
2634
2679
  parseBlock: function(){
2635
- var name = this.expect('block').val.trim();
2636
- var block = 'indent' == this.peek().type
2680
+ var block = this.expect('block')
2681
+ , mode = block.mode
2682
+ , name = block.val.trim();
2683
+
2684
+ block = 'indent' == this.peek().type
2637
2685
  ? this.block()
2638
2686
  : new nodes.Block(new nodes.Literal(''));
2639
- return this.blocks[name] = this.blocks[name] || block;
2687
+
2688
+ var prev = this.blocks[name];
2689
+
2690
+ if (prev) {
2691
+ switch (prev.mode) {
2692
+ case 'append':
2693
+ block.nodes = block.nodes.concat(prev.nodes);
2694
+ prev = block;
2695
+ break;
2696
+ case 'prepend':
2697
+ block.nodes = prev.nodes.concat(block.nodes);
2698
+ prev = block;
2699
+ break;
2700
+ }
2701
+ }
2702
+
2703
+ block.mode = mode;
2704
+ return this.blocks[name] = prev || block;
2640
2705
  },
2641
2706
 
2642
2707
  /**
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jade-js-source
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.19.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,8 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-16 00:00:00.000000000 -05:00
14
- default_executable:
13
+ date: 2011-12-06 00:00:00.000000000Z
15
14
  dependencies: []
16
15
  description: ! " Jade is a high performance template engine heavily influenced
17
16
  by Haml \n and implemented with JavaScript for node.\n"
@@ -23,7 +22,6 @@ files:
23
22
  - lib/jade_js/jade.js
24
23
  - lib/jade_js/runtime.js
25
24
  - lib/jade_js/source.rb
26
- has_rdoc: true
27
25
  homepage: https://github.com/visionmedia/jade
28
26
  licenses: []
29
27
  post_install_message:
@@ -44,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
42
  version: '0'
45
43
  requirements: []
46
44
  rubyforge_project: jade-js-source
47
- rubygems_version: 1.6.2
45
+ rubygems_version: 1.8.12
48
46
  signing_key:
49
47
  specification_version: 3
50
48
  summary: Jade - template engine