Class: Haml::More::CoffeeScript::ClientCompiler

Inherits:
Compiler
  • Object
show all
Defined in:
lib/haml/more/coffee_script.rb

Instance Attribute Summary collapse

Attributes inherited from Compiler

#coffee_directory, #coffee_url

Instance Method Summary collapse

Methods inherited from Compiler

#available?, available_compilers, #compile_statement, #dependencies, #files, inherited, #javascript, new, #not_available!, #urls

Constructor Details

#initializeClientCompiler

Returns a new instance of ClientCompiler.



105
106
107
108
# File 'lib/haml/more/coffee_script.rb', line 105

def initialize
  @script_tag = "<script type=\"text/javascript\" src=%s></script>\n"
  super
end

Instance Attribute Details

#script_tagObject

Returns the value of attribute script_tag.



110
111
112
# File 'lib/haml/more/coffee_script.rb', line 110

def script_tag
  @script_tag
end

#skip_scriptsObject

Returns the value of attribute skip_scripts.



110
111
112
# File 'lib/haml/more/coffee_script.rb', line 110

def skip_scripts
  @skip_scripts
end

Instance Method Details

#render(text) ⇒ Object



115
116
117
118
119
# File 'lib/haml/more/coffee_script.rb', line 115

def render(text)
  result = ""
  urls.each { |u| result << (script_tag % u.inspect) } unless skip_scripts?
  result << javascript("eval(#{compile_statement(text)})")
end

#skip_scripts?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/haml/more/coffee_script.rb', line 111

def skip_scripts?
  !!@skip_scripts
end