mote 0.0.1.rc1 → 0.0.1.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/lib/mote.rb +14 -6
  2. data/mote.gemspec +1 -1
  3. data/test/mote_test.rb +5 -0
  4. metadata +1 -1
data/lib/mote.rb CHANGED
@@ -18,7 +18,7 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
  class Mote
21
- VERSION = "0.0.1.rc1"
21
+ VERSION = "0.0.1.rc2"
22
22
 
23
23
  def self.parse(template, context = self)
24
24
  terms = template.split(/(<%[=#]?)\s*(.*?)\s*%>/)
@@ -41,13 +41,21 @@ class Mote
41
41
 
42
42
  module Helpers
43
43
  def mote(template, params = {})
44
- Mote.parse(template).call(params)
44
+ mote_cache[template] ||= Mote.parse(template)
45
+ mote_cache[template][params]
45
46
  end
46
47
 
47
- def mote_file(file_name, params = {})
48
- @_mote ||= {}
49
- @_mote[file_name] ||= Mote.parse(File.read("#{file_name}.erb"))
50
- @_mote[file_name][params]
48
+ def mote_file(filename, params = {})
49
+ mote_files[filename] ||= Mote.parse(File.read("#{filename}.erb"))
50
+ mote_files[filename][params]
51
+ end
52
+
53
+ def mote_cache
54
+ @_mote_cache ||= {}
55
+ end
56
+
57
+ def mote_files
58
+ @_mote_files ||= {}
51
59
  end
52
60
  end
53
61
  end
data/mote.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "mote"
3
- s.version = "0.0.1.rc1"
3
+ s.version = "0.0.1.rc2"
4
4
  s.summary = "Minimum Operational Template."
5
5
  s.description = "Mote is the little brother of ERB. It only provides a subset of ERB's features, but praises itself of being simple--both internally and externally--and super fast."
6
6
  s.authors = ["Michel Martens"]
data/test/mote_test.rb CHANGED
@@ -26,6 +26,11 @@ scope do
26
26
  assert_equal "***", example[:n => 3]
27
27
  assert_equal "****", example[:n => 4]
28
28
  end
29
+
30
+ test "multiline" do
31
+ example = Mote.parse("The\nMan\nAnd\n<%=\n\"The\"\n%>\nSea")
32
+ assert_equal "The\nMan\nAnd\nThe\nSea", example[:n => 3]
33
+ end
29
34
  end
30
35
 
31
36
  include Mote::Helpers
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mote
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 0.0.1.rc1
5
+ version: 0.0.1.rc2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michel Martens