Module Sinatra::Helpers::Stream::Templates
In: lib/sinatra/base.rb

Template rendering methods. Each method takes the name of a template to render as a Symbol and returns a String with the rendered output, as well as an optional hash with additional options.

`template` is either the name or path of the template as symbol (Use `:’subdir/myview’` for views in subdirectories), or a string that will be rendered.

Possible options are:

  :content_type   The content type to use, same arguments as content_type.
  :layout         If set to false, no layout is rendered, otherwise
                  the specified layout is used (Ignored for `sass` and `less`)
  :layout_engine  Engine to use for rendering the layout.
  :locals         A hash with local variables that should be available
                  in the template
  :scope          If set, template is evaluate with the binding of the given
                  object rather than the application instance.
  :views          Views directory to use.

Methods

builder   coffee   creole   erb   erubis   find_template   haml   less   liquid   markaby   markdown   new   nokogiri   radius   rdoc   sass   scss   slim   textile  

Classes and Modules

Module Sinatra::Helpers::Stream::Templates::ContentTyped

Public Class methods

[Source]

     # File lib/sinatra/base.rb, line 516
516:     def initialize
517:       super
518:       @default_layout = :layout
519:     end

Public Instance methods

[Source]

     # File lib/sinatra/base.rb, line 550
550:     def builder(template=nil, options={}, locals={}, &block)
551:       options[:default_content_type] = :xml
552:       render_ruby(:builder, template, options, locals, &block)
553:     end

[Source]

     # File lib/sinatra/base.rb, line 579
579:     def coffee(template, options={}, locals={})
580:       options.merge! :layout => false, :default_content_type => :js
581:       render :coffee, template, options, locals
582:     end

[Source]

     # File lib/sinatra/base.rb, line 593
593:     def creole(template, options={}, locals={})
594:       render :creole, template, options, locals
595:     end

[Source]

     # File lib/sinatra/base.rb, line 521
521:     def erb(template, options={}, locals={})
522:       render :erb, template, options, locals
523:     end

[Source]

     # File lib/sinatra/base.rb, line 525
525:     def erubis(template, options={}, locals={})
526:       warn "Sinatra::Templates#erubis is deprecated and will be removed, use #erb instead.\n" \
527:         "If you have Erubis installed, it will be used automatically."
528:       render :erubis, template, options, locals
529:     end

Calls the given block for every possible template file in views, named name.ext, where ext is registered on engine.

[Source]

     # File lib/sinatra/base.rb, line 599
599:     def find_template(views, name, engine)
600:       yield ::File.join(views, "#{name}.#{@preferred_extension}")
601:       Tilt.mappings.each do |ext, engines|
602:         next unless ext != @preferred_extension and engines.include? engine
603:         yield ::File.join(views, "#{name}.#{ext}")
604:       end
605:     end

[Source]

     # File lib/sinatra/base.rb, line 531
531:     def haml(template, options={}, locals={})
532:       render :haml, template, options, locals
533:     end

[Source]

     # File lib/sinatra/base.rb, line 545
545:     def less(template, options={}, locals={})
546:       options.merge! :layout => false, :default_content_type => :css
547:       render :less, template, options, locals
548:     end

[Source]

     # File lib/sinatra/base.rb, line 555
555:     def liquid(template, options={}, locals={})
556:       render :liquid, template, options, locals
557:     end

[Source]

     # File lib/sinatra/base.rb, line 575
575:     def markaby(template=nil, options={}, locals={}, &block)
576:       render_ruby(:mab, template, options, locals, &block)
577:     end

[Source]

     # File lib/sinatra/base.rb, line 559
559:     def markdown(template, options={}, locals={})
560:       render :markdown, template, options, locals
561:     end

[Source]

     # File lib/sinatra/base.rb, line 584
584:     def nokogiri(template=nil, options={}, locals={}, &block)
585:       options[:default_content_type] = :xml
586:       render_ruby(:nokogiri, template, options, locals, &block)
587:     end

[Source]

     # File lib/sinatra/base.rb, line 571
571:     def radius(template, options={}, locals={})
572:       render :radius, template, options, locals
573:     end

[Source]

     # File lib/sinatra/base.rb, line 567
567:     def rdoc(template, options={}, locals={})
568:       render :rdoc, template, options, locals
569:     end

[Source]

     # File lib/sinatra/base.rb, line 535
535:     def sass(template, options={}, locals={})
536:       options.merge! :layout => false, :default_content_type => :css
537:       render :sass, template, options, locals
538:     end

[Source]

     # File lib/sinatra/base.rb, line 540
540:     def scss(template, options={}, locals={})
541:       options.merge! :layout => false, :default_content_type => :css
542:       render :scss, template, options, locals
543:     end

[Source]

     # File lib/sinatra/base.rb, line 589
589:     def slim(template, options={}, locals={})
590:       render :slim, template, options, locals
591:     end

[Source]

     # File lib/sinatra/base.rb, line 563
563:     def textile(template, options={}, locals={})
564:       render :textile, template, options, locals
565:     end

[Validate]