jammit-jcarnegie 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/jammit.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'jammit-jcarnegie'
3
- s.version = '0.0.2' # Keep version in sync with jammit.rb
3
+ s.version = '0.0.3' # Keep version in sync with jammit.rb
4
4
  s.date = '2011-07-25'
5
5
 
6
6
  s.homepage = "http://documentcloud.github.com/jammit/"
@@ -102,7 +102,7 @@ module Jammit
102
102
  compiled = paths.map do |path|
103
103
  contents = read_binary_file(path)
104
104
  contents = contents.gsub(/\r?\n/, "\\n").gsub("'", '\\\\\'')
105
- name = template_root ? template_name(path, base_path)
105
+ name = template_name(path, base_path, template_root)
106
106
  "#{namespace}['#{name}'] = #{Jammit.template_function}('#{contents}');"
107
107
  end
108
108
  compiler = Jammit.include_jst_script ? read_binary_file(DEFAULT_JST_SCRIPT) : '';
@@ -129,7 +129,13 @@ module Jammit
129
129
 
130
130
  # Determine the name of a JS template. If there's a common base path, use
131
131
  # the namespaced prefix. Otherwise, simply use the filename.
132
- def template_name(path, base_path)
132
+ def template_name(path, base_path, template_root=nil)
133
+ if template_root
134
+ root = File.join(RAILS_ROOT, template_root)
135
+ path = path.sub(/#{root}/, "")
136
+ dir = File.dirname(path)
137
+ return File.join(dir, File.basename(path, ".#{Jammit.template_extension}"))
138
+ end
133
139
  return File.basename(path, ".#{Jammit.template_extension}") unless base_path
134
140
  path.gsub(/\A#{Regexp.escape(base_path)}\/(.*)\.#{Jammit.template_extension}\Z/, '\1')
135
141
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jammit-jcarnegie
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeremy Ashkenas