Sha256: c670d26d9b52c3907d5878aa134a57d098fedfd4eb446d2773e7b03b032a72d1

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

# Copyright 2013 Google Inc. All Rights Reserved.
# Licensed under the Apache License, Version 2.0, found in the LICENSE file.

require "sinatra"
require "haml"
require "liquid"
require "redcarpet"
require "slim"

class SinatraTemplatesApp < Sinatra::Base
  HELLOS = ["Hello", "Hola", "Bonjour", "Guten Tag",
            "こんにちは", "привет"]

  enable :inline_templates

  get "/erb" do
    erb :erb
  end

  get "/haml" do
    haml :haml
  end

  get "/liquid" do
    liquid :liquid, locals: { hellos: HELLOS }
  end

  get "/slim" do
    slim :slim
  end

  get "/markdown" do
    markdown(:markdown)
  end
end

__END__

@@ erb
<html>
  <body>
    <ul id="hi">
      <% HELLOS.each do |hello| %>
        <li class="greeting"><%= hello %> World!</li>
      <% end %>
    </ul>
  </body>
</html>

@@ haml
%html
  %body
    %ul#hi
      - HELLOS.each do |hello|
        %li.greeting
          =hello
          World!

@@ liquid
<html>
  <body>
    <ul>
      {% for hello in hellos %}
        <li class="greeting">{{ hello }} World!</li>
      {% endfor %}
    </ul>
  </body>
</html>

@@ markdown
* Hello World!
* Hola World!
* Bonjour World!
* Gutentag World!
* こんにちは World!
* привет World!

@@ slim
html
  body
    ul id="hi"
      - HELLOS.each do |hello|
        li.greeting
          = hello
          |  World!

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-allocation_stats-0.1.2 spec/sinatra_templates_app.rb