Module

R2Doc::TemplateUtil

Inheritance

Utility functions available for use in templates

Methods

Class

Visibility Signature
public gen_url (path, target)

Instance

Visibility Signature
public content_tag (tagname, content, html_options = {})
public link_to (content, url, html_options = nil)
public path_to (url)
public render_partial (partial, locals = nil)
public stripe_class (index, class_prefix = '')

Class Method Detail

gen_url(path, target)

Convert a target url to one that is relative to a given path. This method is updated to account for paths to files in the root directory.

Instance Method Detail

content_tag(tagname, content, html_options = {})

Return an html tag with content an attributed defined by the provided hash

link_to(content, url, html_options = nil)

A much simplified and altered version of the link_to method in ActionView::Helpers::UrlHelper, creates a link of the given content to the given url. If url is a string it is assumed to be relative to the top of the documentation directory. If url is a ContextUser object, its path is used. The final URL is adjusted to match the path of the current file being output. If html_options are provided, they become attributes of the returned tag.

path_to(url)

Return the relative path to url for the current file. Assumes that url is a ContextUser or path relative to the top of the documentation directory.

render_partial(partial, locals = nil)

Runs a partial template and return the contents. This is similar to, but much lighter weight than the notion of partials in Rails. Example usage:

  render_partial :foo             # renders the partial in '_foo.html.erb'
  render_partial :foo, {:bar=>1}  # renders the partial and sets local variable bar to 1

stripe_class(index, class_prefix = '')

Returns an even or odd class name for striping rows using a zero-based index