Sha256: 224989004be8241ece98d5ea08910b81bc4ba40e980b0a9acc66b9e755b3f794

Contents?: true

Size: 842 Bytes

Versions: 1

Compression:

Stored size: 842 Bytes

Contents

#
# Installs _wlang_ utility methods on Ruby String. 
#
class String

  # Converts the string to a wlang template
  def wlang_template(dialect="wlang/active-string", context=nil, block_symbols=:braces)
    WLang::Template.new(self, dialect, context, block_symbols)
  end
  
  #
  # Instantiates the string as a wlang template using
  # a context object and a dialect.
  #
  def wlang_instantiate(context=nil, dialect="wlang/active-string", block_symbols=:braces)
    wlang_template(dialect, context, block_symbols).instantiate
  end
  alias :wlang :wlang_instantiate
    
  def __wlang_column_of(index)
    return 1 if index == 0
    newline_index = rindex("\n", index - 1)
    if newline_index
      index - newline_index
    else
      index + 1
    end
  end
  
  def __wlang_line_of(index)
    self[0...index].count("\n") + 1
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wlang-0.8.5 lib/wlang/ruby_extensions.rb