Skip to content

Instantly share code, notes, and snippets.

Last active January 15, 2019 20:39
What would you like to do?
An example that demonstrates a simple app with Sinatra, html templates and jQuery.
curl -X GET http://localhost:4567
require 'sinatra'
require 'erb'
require 'ostruct'
a = :a_symbol_of_good_will
get '/' do
time_to_show =
h = { title: "title",
subtitle: "subtitle",
content: "content" }
post =
template = <<-HTML
<meta charset="utf-8">
<title>Sample app</title>
<section class="container">
<h1><%= post.title %></h1>
<h2><%= post.subtitle %></h2>
<div class="content">
<%= post.content %>
<% (1..6).to_a.each do |v| %>
<div><%= v %></div>
<% end %>
<script src=""></script>
<script type="text/javascript" charset="utf-8">
console.log("hello world");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment