Module: Rcurse

Defined in:
lib/rcurse.rb,
lib/rcurse/engine.rb,
lib/rcurse/helper.rb,
lib/rcurse/context.rb

Overview

Rcurse - super simple template engine

Defined Under Namespace

Classes: Context, Engine, Helper

Class Method Summary (collapse)

Class Method Details

+ (Object) add_helper(helper)

Add a helper to Rcurse, called automatically when creating a helper



5
6
7
# File 'lib/rcurse/helper.rb', line 5

def self.add_helper helper
    @helpers[helper.name] = helper
end

+ (Hash<Rcurse::Helper>) helpers

Available helpers

Returns:

  • (Hash<Rcurse::Helper>) —

    Available helpers, with helper names as keys



12
13
14
# File 'lib/rcurse/helper.rb', line 12

def self.helpers
    @helpers
end

+ (String) render(content, context = Context.new)

Render a template

Parameters:

  • content (String) —

    A String containing the Rcurse template

  • context (Rcurse::Context) (defaults to: Context.new) —

    a context for the template

Returns:

  • (String) —

    The rendered template



73
74
75
76
# File 'lib/rcurse/engine.rb', line 73

def self.render content, context = Context.new
    # proxy
    Rcurse::Engine.render content, context
end

+ (String) render_file(filename, out_filename, context = Context.new)

Render a template file, optionally writing output to another file

Parameters:

  • filename (String) —

    A String containing the Rcurse template

  • out_filename (String) —

    Optional, file to write output to

  • context (Rcurse::Context) (defaults to: Context.new) —

    a context for the template

Returns:

  • (String) —

    The rendered template



79
80
81
82
# File 'lib/rcurse/engine.rb', line 79

def self.render_file filename, out_filename, context = Context.new
    # proxy
    Rcurse::Engine.render_file filename, out_filename, context
end