Module: Ore::Template::Helpers::Textile

Defined in:
lib/ore/template/helpers/textile.rb

Overview

Since:

  • 0.10.0

Instance Method Summary collapse

Instance Method Details

#h1(title) ⇒ String

Emits a Textile h1 heading.

Parameters:

  • title (String)

Returns:

  • (String)

Since:

  • 0.10.0


49
50
51
# File 'lib/ore/template/helpers/textile.rb', line 49

def h1(title)
  "h1. #{title}"
end

#h2(title) ⇒ String

Emits a Textile h2 heading.

Parameters:

  • title (String)

Returns:

  • (String)

Since:

  • 0.10.0


60
61
62
# File 'lib/ore/template/helpers/textile.rb', line 60

def h2(title)
  "h2. #{title}"
end

#h3(title) ⇒ String

Emits a Textile h3 heading.

Parameters:

  • title (String)

Returns:

  • (String)

Since:

  • 0.10.0


71
72
73
# File 'lib/ore/template/helpers/textile.rb', line 71

def h3(title)
  "h3. #{title}"
end

#h4(title) ⇒ String

Emits a Textile h4 heading.

Parameters:

  • title (String)

Returns:

  • (String)

Since:

  • 0.10.0


82
83
84
# File 'lib/ore/template/helpers/textile.rb', line 82

def h4(title)
  "h4. #{title}"
end

#image(url, alt = nil) ⇒ String

Emits a Textile image tag.

Parameters:

  • url (String)
  • alt (String, nil) (defaults to: nil)

Returns:

  • (String)

Since:

  • 0.10.0


36
37
38
39
40
# File 'lib/ore/template/helpers/textile.rb', line 36

def image(url,alt=nil)
  if alt then "!#{url}(#{alt})!"
  else        "!#{url}!"
  end
end

Emits a Textile link.

Parameters:

  • text (String, nil)
  • url (String)

Returns:

  • (String)

Since:

  • 0.10.0


19
20
21
22
23
24
25
# File 'lib/ore/template/helpers/textile.rb', line 19

def link_to(text,url)
  if text
    "#{text.dump}:#{url}"
  else
    url
  end
end

#pre(code) { ... } ⇒ String

Emits a Textile code block.

Parameters:

  • code (String)

Yields:

  • [] The return value of the given block will be used as the code.

Returns:

  • (String)

Since:

  • 0.10.0


96
97
98
99
100
101
102
# File 'lib/ore/template/helpers/textile.rb', line 96

def pre(code)
  if code =~ /#{$/}\s*#{$/}/
    "bc.. #{code}"
  else
    "bc. #{code}"
  end
end