class Parade::Parsers::Dsl
Attributes
@return [Hash] configuration options that the DSL class will use
and pass to other file and directory parsers to ensure the path information is presevered correctly.
Public Class Methods
The parade DSL parse method is used to convert the parade file contents into executable ruby code. This method is also called recursively when a section contains sub-sections to properly parse that data as well.
@param [String,Section] contents the string representation of the parade
dsl contents to be parsed or the current section to be used as the current context.
@param [Hash] options additional options to provide additional
configuration to the parsing process.
def self.parse(contents,options = {})
builder = new builder.options = options config = Proc.new { eval(contents) } builder.instance_eval(&config) builder.current_section
end
# File lib/parade/parsers/dsl.rb, line 29 def self.parse(contents,options = {},&config) builder = new builder.options = options if contents.is_a? Section builder.current_section = contents else config = Proc.new { eval(contents) } end builder.instance_eval(&config) builder.current_section end
Public Instance Methods
This is used by the DSL to specify any additional CSS Classes specific to the section. All slides within the section will receive these additional CSS Classes when the slide is rendered
@example Specifying the css classes in multiple different ways
section "Iteration 0" do css_classes "blue-background" slides "iteration-zero.md" end section "Iteration 1" do css_classes [ "blue-background" ] slides "iteration-zero.md" end section "Iteration WonderWoman" do css_classes "blue-background", "red-font", "white-borders" slides "iteration-zero.md" end section "Iteration Spiderman" do css_classes "blue-background red-spandex web-spitters" slides "iteration-zero.md" end
# File lib/parade/parsers/dsl.rb, line 113 def css_classes(*css_classes) current_section.css_classes = css_classes.flatten.map { |css_class| css_class.split(" ") }.flatten end
@return [String] the current path is the path for the current section
this usually differs from the root_path when parsing sections defined within a section (a sub-section).
# File lib/parade/parsers/dsl.rb, line 160 def current_path if options[:current_path] File.directory?(options[:current_path]) ? options[:current_path] : File.dirname(options[:current_path]) else root_path end end
@return [Section] the current section being built.
# File lib/parade/parsers/dsl.rb, line 171 def current_section @current_section ||= begin new_section = Section.new new_section.add_resource current_path new_section end end
This is used within the DSL to set the description of the current section.
@param [String] new_description the description for the setion.
# File lib/parade/parsers/dsl.rb, line 58 def description(new_description) current_section.description = new_description end
# File lib/parade/parsers/dsl.rb, line 141 def pause_message(message) current_section.pause_message = message end
This is used by the DSL to specify the resources used by the presentation
# File lib/parade/parsers/dsl.rb, line 120 def resources(resource_filepath) current_section.add_resource File.join(options[:current_path], resource_filepath) end
@return [String] the root path where the presentation is being served
from. This path is necessary to ensure that images have the correct image path built for it.
# File lib/parade/parsers/dsl.rb, line 153 def root_path File.directory?(options[:root_path]) ? options[:root_path] : File.dirname(options[:root_path]) end
This is used by the DSL to add additional sections. Adds the specified slides or sub-sections, defined by their filepaths, as a subsection of this section.
# File lib/parade/parsers/dsl.rb, line 67 def section(*filepaths,&block) if block sub_section = Section.new :title => filepaths.flatten.compact.join(" ") section_content = self.class.parse sub_section, options, &block else section_content = Array(filepaths).flatten.compact.map do |filepath| filepath = File.join(current_path,filepath) PresentationFilepathParser.parse(filepath,options) end end current_section.add_section section_content section_content end
# File lib/parade/parsers/dsl.rb, line 85 def template(template_name,template_file) current_section.add_template template_name, File.join(options[:current_path], template_file) end
Sets the current sections theme to the specified theme @note this will only work at the top level section of the presentation
# File lib/parade/parsers/dsl.rb, line 129 def theme(theme_name) current_section.theme = theme_name end
This is used within the DSL to set the title of the current section.
@param [String] new_title the title for the setion.
# File lib/parade/parsers/dsl.rb, line 49 def title(new_title) current_section.title = new_title end