Module: Ramaze::Helper::Ultraviolet

Defined in:
lib/ramaze/helper/ultraviolet.rb

Instance Method Summary collapse

Instance Method Details

#ultraviolet(path, options = {}) ⇒ Object

Parse and output the file at the given path. Please head over to the Ultraviolet documentation for more information on possible options.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ramaze/helper/ultraviolet.rb', line 15

def ultraviolet(path, options = {})
  o = ancestral_trait[:ultraviolet].merge(options)
  output, syntax, lines, style, headers =
    o.values_at(:output, :syntax, :line_numbers, :style, :headers)

  syntax ||= Uv.syntax_for_file(path).first.first
  code = File.read(path)

  p [code, output, syntax, lines, style, headers]
  Uv.parse(code, output, syntax, lines, style, headers)
end

#ultraviolet_css(theme) ⇒ Object

Return absolute path to the css of given name.

Usually this will point to somewhere in the gem tree.

It seems like Uv will add support for user-defined PATH in the future, so we will, to be future-proof, traverse the Uv.path even though it currently will only have one directory.



35
36
37
38
39
40
41
# File 'lib/ramaze/helper/ultraviolet.rb', line 35

def ultraviolet_css(theme)
  Uv.path.each do |path|
    Dir[path/"render/xhtml/files/css/*.css"].each do |css|
      return css if File.basename(css, '.css') == theme
    end
  end
end