tenjin 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,21 @@
2
2
  = CHANGES
3
3
 
4
4
 
5
- == Release 0.7.0
5
+ == Release 0.7.1 (2011-11-27)
6
+
7
+ * [bugfix] Tenjin::Template class now considers magic comment in template file.
8
+ For example:
9
+
10
+ <?rb # -*- coding: utf-8 -*- ?>
11
+ <p>This template file is treated as utf-8 string</p>
12
+
13
+ * [bugfix] Add 'FollowSymLinks' option to 'public_html/.htaccess'.
14
+ That option is necessary to enable mod_rewrite.
15
+
16
+ * [bugfix] Fix 'public_html/hello.rbhtml' to set empty string when request parameter is not set.
17
+
18
+
19
+ == Release 0.7.0 (2011-11-24)
6
20
 
7
21
  * [enhance] Support Ruby 1.9.
8
22
 
data/README.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  = README
2
2
 
3
- release:: 0.7.0
3
+ release:: 0.7.1
4
4
  copyright:: copyright(c) 2007-2011 kuwata-lab.com all rights reserved
5
5
 
6
6
 
@@ -34,11 +34,11 @@ See doc/*.html for details.
34
34
 
35
35
  $ sudo gem install tenjin
36
36
 
37
- * Else download rbtenjin-0.7.0.tar.bz2 and just copy 'lib/tenjin.rb' and
37
+ * Else download rbtenjin-0.7.1.tar.bz2 and just copy 'lib/tenjin.rb' and
38
38
  'bin/rbtenjin' into proper directory.
39
39
 
40
- $ tar xjf rbtenjin-0.7.0.tar.bz2
41
- $ cd rbtenjin-0.7.0/
40
+ $ tar xjf rbtenjin-0.7.1.tar.bz2
41
+ $ cd rbtenjin-0.7.1/
42
42
  $ sudo copy lib/tenjin.rb /usr/local/lib/ruby/1.8/site_ruby/1.8/
43
43
  $ sudo copy bin/rbtenjin /usr/local/bin/
44
44
 
@@ -24,7 +24,7 @@
24
24
  ##
25
25
 
26
26
  ##
27
- ## $Release: 0.7.0 $
27
+ ## $Release: 0.7.1 $
28
28
  ## copyright(c) 2007-2011 kuwata-lab.com all rights reserved
29
29
  ## $License: MIT License $
30
30
  ##
@@ -17,7 +17,7 @@
17
17
  </div>
18
18
 
19
19
  <div align="left">
20
- release: 0.7.0<br>
20
+ release: 0.7.1<br>
21
21
  </div>
22
22
 
23
23
  <div class="toc"><span class="caption">Table of Contents:</span>
@@ -24,14 +24,14 @@
24
24
  ##
25
25
  ## Tenjin -- a very fast and full-featured template engine
26
26
  ##
27
- ## $Release: 0.7.0 $
27
+ ## $Release: 0.7.1 $
28
28
  ## copyright(c) 2007-2011 kuwata-lab.com all rights reserved
29
29
  ## $License: MIT License $
30
30
  ##
31
31
 
32
32
  module Tenjin
33
33
 
34
- RELEASE = ('$Release: 0.7.0 $' =~ /[\d.]+/) && $&
34
+ RELEASE = ('$Release: 0.7.1 $' =~ /[\d.]+/) && $&
35
35
 
36
36
 
37
37
  ##
@@ -760,7 +760,18 @@ module Tenjin
760
760
 
761
761
  ## create proc object
762
762
  def _render() # :nodoc:
763
- return eval("proc { |_context| self._buf = _buf = #{init_buf_expr()}; #{@script}; #{finish_buf_expr()} }".untaint, nil, @filename || '(tenjin)')
763
+ return eval(_to_proc_code(@script).untaint, nil, @filename || '(tenjin)')
764
+ end
765
+
766
+ def _to_proc_code(script)
767
+ ## take care of magic comment when compiling script into proc object
768
+ m = /\A[ \t]*\#.*coding[:=][ \t]*[-.\w]+.*\n/.match(script)
769
+ if m
770
+ pos = m.end(0)
771
+ "#{script[0...pos]}proc do |_context| self._buf = _buf = #{init_buf_expr()}; #{@script[pos..-1]}; #{finish_buf_expr()} end"
772
+ else
773
+ "proc do |_context| self._buf = _buf = #{init_buf_expr()}; #{@script}; #{finish_buf_expr()} end"
774
+ end
764
775
  end
765
776
 
766
777
  public
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'cgi' # or 'cgialt' for performance
4
4
  cgi = CGI.new
5
- name = cgi.params['name'].first
5
+ name = cgi.params['name'].first || ''
6
6
  name = 'World' if name.empty?
7
7
  lang = ENV['HTTP_ACCEPT_LANGUAGE'] =~ /ja/ ? 'ja' : 'en'
8
8
  ?>
@@ -17,7 +17,7 @@
17
17
  ##
18
18
  ## and access to http://localhost/ (or http://localhost/~yourname/).
19
19
  ##
20
- ## $Release: 0.7.0 $
20
+ ## $Release: 0.7.1 $
21
21
  ## copyright(c) 2007-2011 kuwata-lab.com all rights reserved
22
22
  ## $License: MIT License $
23
23
  ##
@@ -2,7 +2,7 @@
2
2
 
3
3
  ###
4
4
  ### $Rev$
5
- ### $Release: 0.7.0 $
5
+ ### $Release: 0.7.1 $
6
6
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
7
7
  ###
8
8
 
@@ -14,7 +14,7 @@ spec = Gem::Specification.new do |s|
14
14
  s.author = "makoto kuwata"
15
15
  s.email = "kwa(at)kuwata-lab.com"
16
16
  s.rubyforge_project = 'tenjin'
17
- s.version = "0.7.0"
17
+ s.version = "0.7.1"
18
18
  s.platform = Gem::Platform::RUBY
19
19
  s.homepage = "http://www.kuwata-lab.com/tenjin/"
20
20
  s.summary = "very fast and full-featured template engine"
@@ -1,5 +1,5 @@
1
1
  ###
2
- ### $Release: 0.7.0 $
2
+ ### $Release: 0.7.1 $
3
3
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
4
4
  ### $License: MIT License $
5
5
  ###
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev$
3
- ### $Release: 0.7.0 $
3
+ ### $Release: 0.7.1 $
4
4
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev$
3
- ### $Release: 0.7.0 $
3
+ ### $Release: 0.7.1 $
4
4
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev$
3
- ### $Release: 0.7.0 $
3
+ ### $Release: 0.7.1 $
4
4
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev$
3
- ### $Release: 0.7.0 $
3
+ ### $Release: 0.7.1 $
4
4
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev$
3
- ### $Release: 0.7.0 $
3
+ ### $Release: 0.7.1 $
4
4
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev$
3
- ### $Release: 0.7.0 $
3
+ ### $Release: 0.7.1 $
4
4
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev$
3
- ### $Release: 0.7.0 $
3
+ ### $Release: 0.7.1 $
4
4
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev$
3
- ### $Release: 0.7.0 $
3
+ ### $Release: 0.7.1 $
4
4
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev$
3
- ### $Release: 0.7.0 $
3
+ ### $Release: 0.7.1 $
4
4
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev$
3
- ### $Release: 0.7.0 $
3
+ ### $Release: 0.7.1 $
4
4
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -161,6 +161,21 @@ END
161
161
  Tenjin::Template.TRACE = false
162
162
  end
163
163
 
164
+ def test_magic_comment
165
+ input = <<'END'
166
+ <?rb # -*- coding: euc-jp -*- ?>
167
+ <p>hello ${@name}!</p>
168
+ END
169
+ t = Tenjin::Template.new
170
+ t.convert(input)
171
+ s = t.__send__(:_to_proc_code, t.script)
172
+ ok_(s) =~ /\A # -\*- coding: euc-jp -\*-\nproc do/
173
+ output = t.render({:name=>"Haruhi"})
174
+ if "".respond_to?(:encoding)
175
+ ok_(output.encoding.to_s) == 'EUC-JP'
176
+ end
177
+ end
178
+
164
179
 
165
180
  end
166
181
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev$
3
- ### $Release: 0.7.0 $
3
+ ### $Release: 0.7.1 $
4
4
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev$
3
- ### $Release: 0.7.0 $
3
+ ### $Release: 0.7.1 $
4
4
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### $Rev$
3
- ### 0.7.0
3
+ ### 0.7.1
4
4
  ### copyright(c) 2007-2011 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tenjin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ hash: 1
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 7
9
+ - 1
10
+ version: 0.7.1
5
11
  platform: ruby
6
12
  authors:
7
13
  - makoto kuwata
@@ -9,8 +15,7 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2011-11-24 00:00:00 +09:00
13
- default_executable:
18
+ date: 2011-11-27 00:00:00 Z
14
19
  dependencies: []
15
20
 
16
21
  description: " Tenjin is a template engine and has the following features.\n * Very fast and lightweight\n * Small and only a file\n * Auto escaping support\n * Auto trimming spaces around embedded statements\n * Context object available\n * Able to load YAML data file\n * Preprocessing support\n"
@@ -251,7 +256,6 @@ files:
251
256
  - public_html/hello.rbhtml
252
257
  - public_html/index.rbhtml
253
258
  - public_html/rbtenjin.cgi
254
- has_rdoc: true
255
259
  homepage: http://www.kuwata-lab.com/tenjin/
256
260
  licenses: []
257
261
 
@@ -261,21 +265,27 @@ rdoc_options: []
261
265
  require_paths:
262
266
  - lib
263
267
  required_ruby_version: !ruby/object:Gem::Requirement
268
+ none: false
264
269
  requirements:
265
270
  - - ">="
266
271
  - !ruby/object:Gem::Version
272
+ hash: 3
273
+ segments:
274
+ - 0
267
275
  version: "0"
268
- version:
269
276
  required_rubygems_version: !ruby/object:Gem::Requirement
277
+ none: false
270
278
  requirements:
271
279
  - - ">="
272
280
  - !ruby/object:Gem::Version
281
+ hash: 3
282
+ segments:
283
+ - 0
273
284
  version: "0"
274
- version:
275
285
  requirements: []
276
286
 
277
287
  rubyforge_project: tenjin
278
- rubygems_version: 1.3.5
288
+ rubygems_version: 1.7.2
279
289
  signing_key:
280
290
  specification_version: 3
281
291
  summary: very fast and full-featured template engine