Skip to content

Latest commit

 

History

History
50 lines (40 loc) · 905 Bytes

adding-tilt-template.adoc

File metadata and controls

50 lines (40 loc) · 905 Bytes

Adding a Tilt Template

Thanks to Jan Thomä for adding this one.

If you need to add a new tilt handler to awestruct, it’s quite simple. Here are the list of instructions:

  1. Add any gems to your Gemfile

    Gemfile
    gem 'typescript-node'
  2. Create the tilt handler

    _ext/typescript_template.rb
    require 'tilt/template'
    require 'typescript-node'
    
    module Tilt
      class TypeScriptTemplate < Template
        self.default_mime_type = 'application/javascript'
    
        def prepare
          options[:filename] ||= file
        end
    
        def evaluate(scope, locals, &block)
          @output ||= TypeScript::Node.compile(data, '--target', 'ES5')
        end
      end
    end
  3. Add the template via pipeline.rb

    require 'typescript'
    
    ::Tilt::register ::Tilt::TypeScriptTemplate, 'ts'