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 506
506:     def initialize
507:       super
508:       @default_layout = :layout
509:     end

Public Instance methods

[Source]

     # File lib/sinatra/base.rb, line 540
540:     def builder(template=nil, options={}, locals={}, &block)
541:       options[:default_content_type] = :xml
542:       render_ruby(:builder, template, options, locals, &block)
543:     end

[Source]

     # File lib/sinatra/base.rb, line 569
569:     def coffee(template, options={}, locals={})
570:       options.merge! :layout => false, :default_content_type => :js
571:       render :coffee, template, options, locals
572:     end

[Source]

     # File lib/sinatra/base.rb, line 583
583:     def creole(template, options={}, locals={})
584:       render :creole, template, options, locals
585:     end

[Source]

     # File lib/sinatra/base.rb, line 511
511:     def erb(template, options={}, locals={})
512:       render :erb, template, options, locals
513:     end

[Source]

     # File lib/sinatra/base.rb, line 515
515:     def erubis(template, options={}, locals={})
516:       warn "Sinatra::Templates#erubis is deprecated and will be removed, use #erb instead.\n" \
517:         "If you have Erubis installed, it will be used automatically."
518:       render :erubis, template, options, locals
519:     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 589
589:     def find_template(views, name, engine)
590:       yield ::File.join(views, "#{name}.#{@preferred_extension}")
591:       Tilt.mappings.each do |ext, engines|
592:         next unless ext != @preferred_extension and engines.include? engine
593:         yield ::File.join(views, "#{name}.#{ext}")
594:       end
595:     end

[Source]

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

[Source]

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

[Source]

     # File lib/sinatra/base.rb, line 545
545:     def liquid(template, options={}, locals={})
546:       render :liquid, template, options, locals
547:     end

[Source]

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

[Source]

     # File lib/sinatra/base.rb, line 549
549:     def markdown(template, options={}, locals={})
550:       render :markdown, template, options, locals
551:     end

[Source]

     # File lib/sinatra/base.rb, line 574
574:     def nokogiri(template=nil, options={}, locals={}, &block)
575:       options[:default_content_type] = :xml
576:       render_ruby(:nokogiri, template, options, locals, &block)
577:     end

[Source]

     # File lib/sinatra/base.rb, line 561
561:     def radius(template, options={}, locals={})
562:       render :radius, template, options, locals
563:     end

[Source]

     # File lib/sinatra/base.rb, line 557
557:     def rdoc(template, options={}, locals={})
558:       render :rdoc, template, options, locals
559:     end

[Source]

     # File lib/sinatra/base.rb, line 525
525:     def sass(template, options={}, locals={})
526:       options.merge! :layout => false, :default_content_type => :css
527:       render :sass, template, options, locals
528:     end

[Source]

     # File lib/sinatra/base.rb, line 530
530:     def scss(template, options={}, locals={})
531:       options.merge! :layout => false, :default_content_type => :css
532:       render :scss, template, options, locals
533:     end

[Source]

     # File lib/sinatra/base.rb, line 579
579:     def slim(template, options={}, locals={})
580:       render :slim, template, options, locals
581:     end

[Source]

     # File lib/sinatra/base.rb, line 553
553:     def textile(template, options={}, locals={})
554:       render :textile, template, options, locals
555:     end

[Validate]