Skip to content

Commit

Permalink
fix typo in test file and expose compiler options using 'options'
Browse files Browse the repository at this point in the history
  • Loading branch information
nghitran committed Mar 22, 2016
1 parent cb1abc5 commit 3d7a569
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/tilt/typescript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@ class TypeScriptTemplate < Template
self.default_mime_type = 'application/javascript'

def prepare
@option_args = []

options.each do |key, value|
next unless value

@option_args << "--#{key}"

if value != true
@option_args << value.to_s
end
end
end

def evaluate(scope, locals, &block)
@output ||= TypeScript::Node.compile(data, '--target', 'ES5')
@output ||= TypeScript::Node.compile(data, *@option_args)
end
end
end
5 changes: 5 additions & 0 deletions test/tile_typescript_test.rb → test/tilt_typescript_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def setup
assert_match @js, template.render
end

test "supports source map" do
template = Tilt::TypeScriptTemplate.new(inlineSourceMap: true) { @ts }
assert_match /sourceMappingURL/, template.render
end

test "can be rendered more than once" do
template = Tilt::TypeScriptTemplate.new { @ts }
3.times { assert_match @js, template.render }
Expand Down

0 comments on commit 3d7a569

Please sign in to comment.