Skip to content

Commit

Permalink
add StaticFreezer, see #82
Browse files Browse the repository at this point in the history
  • Loading branch information
minad committed Dec 4, 2014
1 parent ea4608a commit 62778c5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/temple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module Filters
autoload :ControlFlow, 'temple/filters/control_flow'
autoload :MultiFlattener, 'temple/filters/multi_flattener'
autoload :StaticMerger, 'temple/filters/static_merger'
autoload :StaticFreezer, 'temple/filters/static_freezer'
autoload :DynamicInliner, 'temple/filters/dynamic_inliner'
autoload :Escapable, 'temple/filters/escapable'
autoload :Eraser, 'temple/filters/eraser'
Expand Down
9 changes: 9 additions & 0 deletions lib/temple/filters/static_freezer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Temple
module Filters
class StaticFreezer < Filter
def on_static(str)
[:dynamic, "#{str.inspect}.freeze"]
end
end
end
end
11 changes: 11 additions & 0 deletions test/filters/test_static_freezer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'helper'

describe Temple::Filters::StaticFreezer do
before do
@filter = Temple::Filters::StaticFreezer.new
end

it 'should freeze static' do
@filter.call([:static, 'hi']).should.equal [:dynamic, '"hi".freeze']
end
end

0 comments on commit 62778c5

Please sign in to comment.