Skip to content

Commit

Permalink
Added the option to guard a partial when it is rendered from subsequent
Browse files Browse the repository at this point in the history
filters.
  • Loading branch information
TwP committed May 31, 2008
1 parent 8f2cde7 commit 5f53c33
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 0 additions & 2 deletions examples/presentation/content/_sample_code.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
---
filter: erb
---
<notextile>
<% uv :lang => "ruby", :theme => 'twilight' do -%>
class A
def method()
puts "in class #{self.class.name}"
end
end
<% end -%>
</notextile>
2 changes: 1 addition & 1 deletion examples/presentation/content/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ h1. Title of the Third Slide

This code comes from a partial

<%= render_partial('sample_code') %>
<%= render_partial 'sample_code', :guard => true %>


h1. Title of the Fourth Slide
Expand Down
10 changes: 9 additions & 1 deletion lib/webby/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,15 @@ def render_page
def render_partial( part, opts = {} )
part = _find_partial(part)

_track_rendering(part.path) {
str = _track_rendering(part.path) {
_configure_locals(opts[:locals])
Filters.process(self, part, ::Webby::Resources::File.read(part.path))
}

# TODO: add documentation / examples for the guard option

str = _guard(str) if opts[:guard]
str
end

# call-seq:
Expand Down Expand Up @@ -256,6 +261,9 @@ def _configure_locals( locals )
# Raies a Webby::Error if the partial could not be found.
#
def _find_partial( part )

# FIXME: this won't work for partial names with paths

case part
when String
fn = '_' + part
Expand Down

0 comments on commit 5f53c33

Please sign in to comment.