Class: GHWikiTools::Snippet

Inherits:
Page
  • Object
show all
Defined in:
lib/ghwikitools/snippet.rb

Overview

Snippet is a small block text of wiki page.

Instance Attribute Summary

Attributes inherited from Page

#ext, #lang, #name, #path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Page

all, by_filename, #delete_snippet, #find_snippets, #include_snippet?, #initialize, #insert_footer, #insert_header, #render_snippets, #update_snippets, #valid?, #wikiname

Constructor Details

This class inherits a constructor from GHWikiTools::Page

Class Method Details

.dirObject

Return snippetss directory.



6
7
8
# File 'lib/ghwikitools/snippet.rb', line 6

def dir
  GHWikiTools.dir + "snippet"
end

Instance Method Details

#render(page) ⇒ Object

Render the snippet with the page.

Parameters:

  • page (Page)

    the page that the snippet embeds in it



15
16
17
# File 'lib/ghwikitools/snippet.rb', line 15

def render(page)
  ERB.new(@path.read, nil, 2).result(SnippetContext.create(page))
end