sinatra 2.2.3 → 3.0.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sinatra might be problematic. Click here for more details.

data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Sinatra
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/sinatra.svg)](https://badge.fury.io/rb/sinatra)
4
- [![Build Status](https://secure.travis-ci.org/sinatra/sinatra.svg)](https://travis-ci.org/sinatra/sinatra)
5
- [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=sinatra&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sinatra&package-manager=bundler&version-scheme=semver)
4
+ [![Testing](https://github.com/sinatra/sinatra/actions/workflows/test.yml/badge.svg)](https://github.com/sinatra/sinatra/actions/workflows/test.yml)
6
5
 
7
6
  Sinatra is a [DSL](https://en.wikipedia.org/wiki/Domain-specific_language) for
8
7
  quickly creating web applications in Ruby with minimal effort:
@@ -20,6 +19,7 @@ Install the gem:
20
19
 
21
20
  ```shell
22
21
  gem install sinatra
22
+ gem install puma # or any other server
23
23
  ```
24
24
 
25
25
  And run with:
@@ -31,101 +31,92 @@ ruby myapp.rb
31
31
  View at: [http://localhost:4567](http://localhost:4567)
32
32
 
33
33
  The code you changed will not take effect until you restart the server.
34
- Please restart the server every time you change or use
35
- [sinatra/reloader](http://www.sinatrarb.com/contrib/reloader).
34
+ Please restart the server every time you change or use a code reloader
35
+ like [rerun](https://github.com/alexch/rerun) or
36
+ [rack-unreloader](https://github.com/jeremyevans/rack-unreloader).
36
37
 
37
38
  It is recommended to also run `gem install puma`, which Sinatra will
38
39
  pick up if available.
39
40
 
40
41
  ## Table of Contents
41
42
 
42
- * [Sinatra](#sinatra)
43
- * [Table of Contents](#table-of-contents)
44
- * [Routes](#routes)
45
- * [Conditions](#conditions)
46
- * [Return Values](#return-values)
47
- * [Custom Route Matchers](#custom-route-matchers)
48
- * [Static Files](#static-files)
49
- * [Views / Templates](#views--templates)
50
- * [Literal Templates](#literal-templates)
51
- * [Available Template Languages](#available-template-languages)
52
- * [Haml Templates](#haml-templates)
53
- * [Erb Templates](#erb-templates)
54
- * [Builder Templates](#builder-templates)
55
- * [Nokogiri Templates](#nokogiri-templates)
56
- * [Sass Templates](#sass-templates)
57
- * [SCSS Templates](#scss-templates)
58
- * [Less Templates](#less-templates)
59
- * [Liquid Templates](#liquid-templates)
60
- * [Markdown Templates](#markdown-templates)
61
- * [Textile Templates](#textile-templates)
62
- * [RDoc Templates](#rdoc-templates)
63
- * [AsciiDoc Templates](#asciidoc-templates)
64
- * [Radius Templates](#radius-templates)
65
- * [Markaby Templates](#markaby-templates)
66
- * [RABL Templates](#rabl-templates)
67
- * [Slim Templates](#slim-templates)
68
- * [Creole Templates](#creole-templates)
69
- * [MediaWiki Templates](#mediawiki-templates)
70
- * [CoffeeScript Templates](#coffeescript-templates)
71
- * [Stylus Templates](#stylus-templates)
72
- * [Yajl Templates](#yajl-templates)
73
- * [WLang Templates](#wlang-templates)
74
- * [Accessing Variables in Templates](#accessing-variables-in-templates)
75
- * [Templates with `yield` and nested layouts](#templates-with-yield-and-nested-layouts)
76
- * [Inline Templates](#inline-templates)
77
- * [Named Templates](#named-templates)
78
- * [Associating File Extensions](#associating-file-extensions)
79
- * [Adding Your Own Template Engine](#adding-your-own-template-engine)
80
- * [Using Custom Logic for Template Lookup](#using-custom-logic-for-template-lookup)
81
- * [Filters](#filters)
82
- * [Helpers](#helpers)
83
- * [Using Sessions](#using-sessions)
84
- * [Session Secret Security](#session-secret-security)
85
- * [Session Config](#session-config)
86
- * [Choosing Your Own Session Middleware](#choosing-your-own-session-middleware)
87
- * [Halting](#halting)
88
- * [Passing](#passing)
89
- * [Triggering Another Route](#triggering-another-route)
90
- * [Setting Body, Status Code and Headers](#setting-body-status-code-and-headers)
91
- * [Streaming Responses](#streaming-responses)
92
- * [Logging](#logging)
93
- * [Mime Types](#mime-types)
94
- * [Generating URLs](#generating-urls)
95
- * [Browser Redirect](#browser-redirect)
96
- * [Cache Control](#cache-control)
97
- * [Sending Files](#sending-files)
98
- * [Accessing the Request Object](#accessing-the-request-object)
99
- * [Attachments](#attachments)
100
- * [Dealing with Date and Time](#dealing-with-date-and-time)
101
- * [Looking Up Template Files](#looking-up-template-files)
102
- * [Configuration](#configuration)
103
- * [Configuring attack protection](#configuring-attack-protection)
104
- * [Available Settings](#available-settings)
105
- * [Environments](#environments)
106
- * [Error Handling](#error-handling)
107
- * [Not Found](#not-found)
108
- * [Error](#error)
109
- * [Rack Middleware](#rack-middleware)
110
- * [Testing](#testing)
111
- * [Sinatra::Base - Middleware, Libraries, and Modular Apps](#sinatrabase---middleware-libraries-and-modular-apps)
112
- * [Modular vs. Classic Style](#modular-vs-classic-style)
113
- * [Serving a Modular Application](#serving-a-modular-application)
114
- * [Using a Classic Style Application with a config.ru](#using-a-classic-style-application-with-a-configru)
115
- * [When to use a config.ru?](#when-to-use-a-configru)
116
- * [Using Sinatra as Middleware](#using-sinatra-as-middleware)
117
- * [Dynamic Application Creation](#dynamic-application-creation)
118
- * [Scopes and Binding](#scopes-and-binding)
119
- * [Application/Class Scope](#applicationclass-scope)
120
- * [Request/Instance Scope](#requestinstance-scope)
121
- * [Delegation Scope](#delegation-scope)
122
- * [Command Line](#command-line)
123
- * [Multi-threading](#multi-threading)
124
- * [Requirement](#requirement)
125
- * [The Bleeding Edge](#the-bleeding-edge)
126
- * [With Bundler](#with-bundler)
127
- * [Versioning](#versioning)
128
- * [Further Reading](#further-reading)
43
+ - [Sinatra](#sinatra)
44
+ - [Table of Contents](#table-of-contents)
45
+ - [Routes](#routes)
46
+ - [Conditions](#conditions)
47
+ - [Return Values](#return-values)
48
+ - [Custom Route Matchers](#custom-route-matchers)
49
+ - [Static Files](#static-files)
50
+ - [Views / Templates](#views--templates)
51
+ - [Literal Templates](#literal-templates)
52
+ - [Available Template Languages](#available-template-languages)
53
+ - [Haml Templates](#haml-templates)
54
+ - [Erb Templates](#erb-templates)
55
+ - [Builder Templates](#builder-templates)
56
+ - [Nokogiri Templates](#nokogiri-templates)
57
+ - [Liquid Templates](#liquid-templates)
58
+ - [Markdown Templates](#markdown-templates)
59
+ - [RDoc Templates](#rdoc-templates)
60
+ - [AsciiDoc Templates](#asciidoc-templates)
61
+ - [Markaby Templates](#markaby-templates)
62
+ - [RABL Templates](#rabl-templates)
63
+ - [Slim Templates](#slim-templates)
64
+ - [Yajl Templates](#yajl-templates)
65
+ - [Accessing Variables in Templates](#accessing-variables-in-templates)
66
+ - [Templates with `yield` and nested layouts](#templates-with-yield-and-nested-layouts)
67
+ - [Inline Templates](#inline-templates)
68
+ - [Named Templates](#named-templates)
69
+ - [Associating File Extensions](#associating-file-extensions)
70
+ - [Adding Your Own Template Engine](#adding-your-own-template-engine)
71
+ - [Using Custom Logic for Template Lookup](#using-custom-logic-for-template-lookup)
72
+ - [Filters](#filters)
73
+ - [Helpers](#helpers)
74
+ - [Using Sessions](#using-sessions)
75
+ - [Session Secret Security](#session-secret-security)
76
+ - [Session Config](#session-config)
77
+ - [Choosing Your Own Session Middleware](#choosing-your-own-session-middleware)
78
+ - [Halting](#halting)
79
+ - [Passing](#passing)
80
+ - [Triggering Another Route](#triggering-another-route)
81
+ - [Setting Body, Status Code, and Headers](#setting-body-status-code-and-headers)
82
+ - [Streaming Responses](#streaming-responses)
83
+ - [Logging](#logging)
84
+ - [Mime Types](#mime-types)
85
+ - [Generating URLs](#generating-urls)
86
+ - [Browser Redirect](#browser-redirect)
87
+ - [Cache Control](#cache-control)
88
+ - [Sending Files](#sending-files)
89
+ - [Accessing the Request Object](#accessing-the-request-object)
90
+ - [Attachments](#attachments)
91
+ - [Dealing with Date and Time](#dealing-with-date-and-time)
92
+ - [Looking Up Template Files](#looking-up-template-files)
93
+ - [Configuration](#configuration)
94
+ - [Configuring attack protection](#configuring-attack-protection)
95
+ - [Available Settings](#available-settings)
96
+ - [Environments](#environments)
97
+ - [Error Handling](#error-handling)
98
+ - [Not Found](#not-found)
99
+ - [Error](#error)
100
+ - [Rack Middleware](#rack-middleware)
101
+ - [Testing](#testing)
102
+ - [Sinatra::Base - Middleware, Libraries, and Modular Apps](#sinatrabase---middleware-libraries-and-modular-apps)
103
+ - [Modular vs. Classic Style](#modular-vs-classic-style)
104
+ - [Serving a Modular Application](#serving-a-modular-application)
105
+ - [Using a Classic Style Application with a config.ru](#using-a-classic-style-application-with-a-configru)
106
+ - [When to use a config.ru?](#when-to-use-a-configru)
107
+ - [Using Sinatra as Middleware](#using-sinatra-as-middleware)
108
+ - [Dynamic Application Creation](#dynamic-application-creation)
109
+ - [Scopes and Binding](#scopes-and-binding)
110
+ - [Application/Class Scope](#applicationclass-scope)
111
+ - [Request/Instance Scope](#requestinstance-scope)
112
+ - [Delegation Scope](#delegation-scope)
113
+ - [Command Line](#command-line)
114
+ - [Multi-threading](#multi-threading)
115
+ - [Requirement](#requirement)
116
+ - [The Bleeding Edge](#the-bleeding-edge)
117
+ - [With Bundler](#with-bundler)
118
+ - [Versioning](#versioning)
119
+ - [Further Reading](#further-reading)
129
120
 
130
121
  ## Routes
131
122
 
@@ -382,15 +373,16 @@ stop there. You can easily define your own matchers:
382
373
 
383
374
  ```ruby
384
375
  class AllButPattern
385
- Match = Struct.new(:captures)
386
-
387
376
  def initialize(except)
388
- @except = except
389
- @captures = Match.new([])
377
+ @except = except
378
+ end
379
+
380
+ def to_pattern(options)
381
+ return self
390
382
  end
391
383
 
392
- def match(str)
393
- @captures unless @except === str
384
+ def params(route)
385
+ return {} unless @except === route
394
386
  end
395
387
  end
396
388
 
@@ -407,20 +399,12 @@ Note that the above example might be over-engineered, as it can also be
407
399
  expressed as:
408
400
 
409
401
  ```ruby
410
- get // do
402
+ get /.*/ do
411
403
  pass if request.path_info == "/index"
412
404
  # ...
413
405
  end
414
406
  ```
415
407
 
416
- Or, using negative look ahead:
417
-
418
- ```ruby
419
- get %r{(?!/index)} do
420
- # ...
421
- end
422
- ```
423
-
424
408
  ## Static Files
425
409
 
426
410
  Static files are served from the `./public` directory. You can specify
@@ -584,7 +568,7 @@ Some languages have multiple implementations. To specify what implementation
584
568
  to use (and to be thread-safe), you should simply require it first:
585
569
 
586
570
  ```ruby
587
- require 'rdiscount' # or require 'bluecloth'
571
+ require 'rdiscount'
588
572
  get('/') { markdown :index }
589
573
  ```
590
574
 
@@ -612,14 +596,12 @@ get('/') { markdown :index }
612
596
  <td>Dependency</td>
613
597
  <td>
614
598
  <a href="https://github.com/jeremyevans/erubi" title="erubi">erubi</a>
615
- or <a href="http://www.kuwata-lab.com/erubis/" title="erubis">erubis</a>
616
599
  or erb (included in Ruby)
617
600
  </td>
618
601
  </tr>
619
602
  <tr>
620
603
  <td>File Extensions</td>
621
- <td><tt>.erb</tt>, <tt>.rhtml</tt> or <tt>.erubi</tt> (Erubi only)
622
- or <tt>.erubis</tt> (Erubis only)</td>
604
+ <td><tt>.erb</tt>, <tt>.rhtml</tt> or <tt>.erubi</tt> (Erubi only)</td>
623
605
  </tr>
624
606
  <tr>
625
607
  <td>Example</td>
@@ -667,56 +649,6 @@ It also takes a block for inline templates (see [example](#inline-templates)).
667
649
 
668
650
  It also takes a block for inline templates (see [example](#inline-templates)).
669
651
 
670
- #### Sass Templates
671
-
672
- <table>
673
- <tr>
674
- <td>Dependency</td>
675
- <td><a href="https://sass-lang.com/" title="sass">sass</a></td>
676
- </tr>
677
- <tr>
678
- <td>File Extension</td>
679
- <td><tt>.sass</tt></td>
680
- </tr>
681
- <tr>
682
- <td>Example</td>
683
- <td><tt>sass :stylesheet, :style => :expanded</tt></td>
684
- </tr>
685
- </table>
686
-
687
- #### SCSS Templates
688
-
689
- <table>
690
- <tr>
691
- <td>Dependency</td>
692
- <td><a href="https://sass-lang.com/" title="sass">sass</a></td>
693
- </tr>
694
- <tr>
695
- <td>File Extension</td>
696
- <td><tt>.scss</tt></td>
697
- </tr>
698
- <tr>
699
- <td>Example</td>
700
- <td><tt>scss :stylesheet, :style => :expanded</tt></td>
701
- </tr>
702
- </table>
703
-
704
- #### Less Templates
705
-
706
- <table>
707
- <tr>
708
- <td>Dependency</td>
709
- <td><a href="http://lesscss.org/" title="less">less</a></td>
710
- </tr>
711
- <tr>
712
- <td>File Extension</td>
713
- <td><tt>.less</tt></td>
714
- </tr>
715
- <tr>
716
- <td>Example</td>
717
- <td><tt>less :stylesheet</tt></td>
718
- </tr>
719
- </table>
720
652
 
721
653
  #### Liquid Templates
722
654
 
@@ -747,9 +679,7 @@ template, you almost always want to pass locals to it.
747
679
  Anyone of:
748
680
  <a href="https://github.com/davidfstr/rdiscount" title="RDiscount">RDiscount</a>,
749
681
  <a href="https://github.com/vmg/redcarpet" title="RedCarpet">RedCarpet</a>,
750
- <a href="https://github.com/ged/bluecloth" title="BlueCloth">BlueCloth</a>,
751
682
  <a href="https://kramdown.gettalong.org/" title="kramdown">kramdown</a>,
752
- <a href="https://github.com/bhollis/maruku" title="maruku">maruku</a>
753
683
  <a href="https://github.com/gjtorikian/commonmarker" title="commonmarker">commonmarker</a>
754
684
  <a href="https://github.com/alphabetum/pandoc-ruby" title="pandoc">pandoc</a>
755
685
  </td>
@@ -784,42 +714,6 @@ Since you cannot call Ruby from Markdown, you cannot use layouts written in
784
714
  Markdown. However, it is possible to use another rendering engine for the
785
715
  template than for the layout by passing the `:layout_engine` option.
786
716
 
787
- #### Textile Templates
788
-
789
- <table>
790
- <tr>
791
- <td>Dependency</td>
792
- <td><a href="http://redcloth.org/" title="RedCloth">RedCloth</a></td>
793
- </tr>
794
- <tr>
795
- <td>File Extension</td>
796
- <td><tt>.textile</tt></td>
797
- </tr>
798
- <tr>
799
- <td>Example</td>
800
- <td><tt>textile :index, :layout_engine => :erb</tt></td>
801
- </tr>
802
- </table>
803
-
804
- It is not possible to call methods from Textile, nor to pass locals to
805
- it. You therefore will usually use it in combination with another
806
- rendering engine:
807
-
808
- ```ruby
809
- erb :overview, :locals => { :text => textile(:introduction) }
810
- ```
811
-
812
- Note that you may also call the `textile` method from within other templates:
813
-
814
- ```ruby
815
- %h1 Hello From Haml!
816
- %p= textile(:greetings)
817
- ```
818
-
819
- Since you cannot call Ruby from Textile, you cannot use layouts written in
820
- Textile. However, it is possible to use another rendering engine for the
821
- template than for the layout by passing the `:layout_engine` option.
822
-
823
717
  #### RDoc Templates
824
718
 
825
719
  <table>
@@ -875,26 +769,6 @@ template than for the layout by passing the `:layout_engine` option.
875
769
  Since you cannot call Ruby methods directly from an AsciiDoc template, you
876
770
  almost always want to pass locals to it.
877
771
 
878
- #### Radius Templates
879
-
880
- <table>
881
- <tr>
882
- <td>Dependency</td>
883
- <td><a href="https://github.com/jlong/radius" title="Radius">Radius</a></td>
884
- </tr>
885
- <tr>
886
- <td>File Extension</td>
887
- <td><tt>.radius</tt></td>
888
- </tr>
889
- <tr>
890
- <td>Example</td>
891
- <td><tt>radius :index, :locals => { :key => 'value' }</tt></td>
892
- </tr>
893
- </table>
894
-
895
- Since you cannot call Ruby methods directly from a Radius template, you
896
- almost always want to pass locals to it.
897
-
898
772
  #### Markaby Templates
899
773
 
900
774
  <table>
@@ -948,139 +822,6 @@ It also takes a block for inline templates (see [example](#inline-templates)).
948
822
  </tr>
949
823
  </table>
950
824
 
951
- #### Creole Templates
952
-
953
- <table>
954
- <tr>
955
- <td>Dependency</td>
956
- <td><a href="https://github.com/minad/creole" title="Creole">Creole</a></td>
957
- </tr>
958
- <tr>
959
- <td>File Extension</td>
960
- <td><tt>.creole</tt></td>
961
- </tr>
962
- <tr>
963
- <td>Example</td>
964
- <td><tt>creole :wiki, :layout_engine => :erb</tt></td>
965
- </tr>
966
- </table>
967
-
968
- It is not possible to call methods from Creole, nor to pass locals to it. You
969
- therefore will usually use it in combination with another rendering engine:
970
-
971
- ```ruby
972
- erb :overview, :locals => { :text => creole(:introduction) }
973
- ```
974
-
975
- Note that you may also call the `creole` method from within other templates:
976
-
977
- ```ruby
978
- %h1 Hello From Haml!
979
- %p= creole(:greetings)
980
- ```
981
-
982
- Since you cannot call Ruby from Creole, you cannot use layouts written in
983
- Creole. However, it is possible to use another rendering engine for the
984
- template than for the layout by passing the `:layout_engine` option.
985
-
986
- #### MediaWiki Templates
987
-
988
- <table>
989
- <tr>
990
- <td>Dependency</td>
991
- <td><a href="https://github.com/nricciar/wikicloth" title="WikiCloth">WikiCloth</a></td>
992
- </tr>
993
- <tr>
994
- <td>File Extension</td>
995
- <td><tt>.mediawiki</tt> and <tt>.mw</tt></td>
996
- </tr>
997
- <tr>
998
- <td>Example</td>
999
- <td><tt>mediawiki :wiki, :layout_engine => :erb</tt></td>
1000
- </tr>
1001
- </table>
1002
-
1003
- It is not possible to call methods from MediaWiki markup, nor to pass
1004
- locals to it. You therefore will usually use it in combination with
1005
- another rendering engine:
1006
-
1007
- ```ruby
1008
- erb :overview, :locals => { :text => mediawiki(:introduction) }
1009
- ```
1010
-
1011
- Note that you may also call the `mediawiki` method from within other
1012
- templates:
1013
-
1014
- ```ruby
1015
- %h1 Hello From Haml!
1016
- %p= mediawiki(:greetings)
1017
- ```
1018
-
1019
- Since you cannot call Ruby from MediaWiki, you cannot use layouts written in
1020
- MediaWiki. However, it is possible to use another rendering engine for the
1021
- template than for the layout by passing the `:layout_engine` option.
1022
-
1023
- #### CoffeeScript Templates
1024
-
1025
- <table>
1026
- <tr>
1027
- <td>Dependency</td>
1028
- <td>
1029
- <a href="https://github.com/josh/ruby-coffee-script" title="Ruby CoffeeScript">
1030
- CoffeeScript
1031
- </a> and a
1032
- <a href="https://github.com/sstephenson/execjs" title="ExecJS">
1033
- way to execute javascript
1034
- </a>
1035
- </td>
1036
- </tr>
1037
- <tr>
1038
- <td>File Extension</td>
1039
- <td><tt>.coffee</tt></td>
1040
- </tr>
1041
- <tr>
1042
- <td>Example</td>
1043
- <td><tt>coffee :index</tt></td>
1044
- </tr>
1045
- </table>
1046
-
1047
- #### Stylus Templates
1048
-
1049
- <table>
1050
- <tr>
1051
- <td>Dependency</td>
1052
- <td>
1053
- <a href="https://github.com/forgecrafted/ruby-stylus" title="Ruby Stylus">
1054
- Stylus
1055
- </a> and a
1056
- <a href="https://github.com/sstephenson/execjs" title="ExecJS">
1057
- way to execute javascript
1058
- </a>
1059
- </td>
1060
- </tr>
1061
- <tr>
1062
- <td>File Extension</td>
1063
- <td><tt>.styl</tt></td>
1064
- </tr>
1065
- <tr>
1066
- <td>Example</td>
1067
- <td><tt>stylus :index</tt></td>
1068
- </tr>
1069
- </table>
1070
-
1071
- Before being able to use Stylus templates, you need to load `stylus` and
1072
- `stylus/tilt` first:
1073
-
1074
- ```ruby
1075
- require 'sinatra'
1076
- require 'stylus'
1077
- require 'stylus/tilt'
1078
-
1079
- get '/' do
1080
- stylus :example
1081
- end
1082
- ```
1083
-
1084
825
  #### Yajl Templates
1085
826
 
1086
827
  <table>
@@ -1122,27 +863,6 @@ var resource = {"foo":"bar","baz":"qux"};
1122
863
  present(resource);
1123
864
  ```
1124
865
 
1125
- #### WLang Templates
1126
-
1127
- <table>
1128
- <tr>
1129
- <td>Dependency</td>
1130
- <td><a href="https://github.com/blambeau/wlang" title="WLang">WLang</a></td>
1131
- </tr>
1132
- <tr>
1133
- <td>File Extension</td>
1134
- <td><tt>.wlang</tt></td>
1135
- </tr>
1136
- <tr>
1137
- <td>Example</td>
1138
- <td><tt>wlang :index, :locals => { :key => 'value' }</tt></td>
1139
- </tr>
1140
- </table>
1141
-
1142
- Since calling ruby methods is not idiomatic in WLang, you almost always
1143
- want to pass locals to it. Layouts written in WLang and `yield` are
1144
- supported, though.
1145
-
1146
866
  ### Accessing Variables in Templates
1147
867
 
1148
868
  Templates are evaluated within the same context as route handlers. Instance
@@ -1201,7 +921,7 @@ end
1201
921
  ```
1202
922
 
1203
923
  Currently, the following rendering methods accept a block: `erb`, `haml`,
1204
- `liquid`, `slim `, `wlang`. Also, the general `render` method accepts a block.
924
+ `liquid`, `slim `. Also, the general `render` method accepts a block.
1205
925
 
1206
926
  ### Inline Templates
1207
927
 
@@ -1218,7 +938,7 @@ __END__
1218
938
 
1219
939
  @@ layout
1220
940
  %html
1221
- = yield
941
+ != yield
1222
942
 
1223
943
  @@ index
1224
944
  %div.title Hello world.
@@ -1261,10 +981,10 @@ end
1261
981
 
1262
982
  To associate a file extension with a template engine, use
1263
983
  `Tilt.register`. For instance, if you like to use the file extension
1264
- `tt` for Textile templates, you can do the following:
984
+ `tt` for Haml templates, you can do the following:
1265
985
 
1266
986
  ```ruby
1267
- Tilt.register :tt, Tilt[:textile]
987
+ Tilt.register Tilt[:haml], :tt
1268
988
  ```
1269
989
 
1270
990
  ### Adding Your Own Template Engine
@@ -1272,7 +992,7 @@ Tilt.register :tt, Tilt[:textile]
1272
992
  First, register your engine with Tilt, then create a rendering method:
1273
993
 
1274
994
  ```ruby
1275
- Tilt.register :myat, MyAwesomeTemplateEngine
995
+ Tilt.register MyAwesomeTemplateEngine, :myat
1276
996
 
1277
997
  helpers do
1278
998
  def myat(*args) render(:myat, *args) end
@@ -2136,7 +1856,7 @@ end
2136
1856
  Another example would be using different directories for different engines:
2137
1857
 
2138
1858
  ```ruby
2139
- set :views, :sass => 'views/sass', :haml => 'templates', :default => 'views'
1859
+ set :views, :haml => 'templates', :default => 'views'
2140
1860
 
2141
1861
  helpers do
2142
1862
  def find_template(views, name, engine, &block)
@@ -2213,7 +1933,7 @@ end
2213
1933
  ### Configuring attack protection
2214
1934
 
2215
1935
  Sinatra is using
2216
- [Rack::Protection](https://github.com/sinatra/sinatra/tree/master/rack-protection#readme) to
1936
+ [Rack::Protection](https://github.com/sinatra/sinatra/tree/main/rack-protection#readme) to
2217
1937
  defend your application against common, opportunistic attacks. You can
2218
1938
  easily disable this behavior (which will open up your application to tons
2219
1939
  of common vulnerabilities):
@@ -2599,7 +2319,7 @@ end
2599
2319
  ```
2600
2320
 
2601
2321
  The semantics of `use` are identical to those defined for the
2602
- [Rack::Builder](http://www.rubydoc.info/github/rack/rack/master/Rack/Builder) DSL
2322
+ [Rack::Builder](https://www.rubydoc.info/github/rack/rack/main/Rack/Builder) DSL
2603
2323
  (most frequently used from rackup files). For example, the `use` method
2604
2324
  accepts multiple/variable args as well as blocks:
2605
2325
 
@@ -2615,7 +2335,7 @@ many of these components automatically based on configuration so you
2615
2335
  typically don't have to `use` them explicitly.
2616
2336
 
2617
2337
  You can find useful middleware in
2618
- [rack](https://github.com/rack/rack/tree/master/lib/rack),
2338
+ [rack](https://github.com/rack/rack/tree/main/lib/rack),
2619
2339
  [rack-contrib](https://github.com/rack/rack-contrib#readme),
2620
2340
  or in the [Rack wiki](https://github.com/rack/rack/wiki/List-of-Middleware).
2621
2341
 
@@ -2623,7 +2343,7 @@ or in the [Rack wiki](https://github.com/rack/rack/wiki/List-of-Middleware).
2623
2343
 
2624
2344
  Sinatra tests can be written using any Rack-based testing library or
2625
2345
  framework.
2626
- [Rack::Test](http://www.rubydoc.info/github/brynary/rack-test/master/frames)
2346
+ [Rack::Test](https://www.rubydoc.info/github/rack/rack-test/main/frames)
2627
2347
  is recommended:
2628
2348
 
2629
2349
  ```ruby
@@ -3085,9 +2805,9 @@ rainbows -c rainbows.conf
3085
2805
 
3086
2806
  The following Ruby versions are officially supported:
3087
2807
  <dl>
3088
- <dt>Ruby 2.3</dt>
2808
+ <dt>Ruby 2.6</dt>
3089
2809
  <dd>
3090
- 2.3 is fully supported and recommended. There are currently no plans to
2810
+ 2.6 is fully supported and recommended. There are currently no plans to
3091
2811
  drop official support for it.
3092
2812
  </dd>
3093
2813
 
@@ -3105,37 +2825,20 @@ The following Ruby versions are officially supported:
3105
2825
  </dd>
3106
2826
  </dl>
3107
2827
 
3108
- Versions of Ruby before 2.3 are no longer supported as of Sinatra 2.1.0.
3109
-
3110
- We also keep an eye on upcoming Ruby versions.
3111
-
3112
- The following Ruby implementations are not officially supported but still are
3113
- known to run Sinatra:
2828
+ Versions of Ruby before 2.6 are no longer supported as of Sinatra 3.0.0.
3114
2829
 
3115
- * Older versions of JRuby and Rubinius
3116
- * Ruby Enterprise Edition
3117
- * MacRuby, Maglev, IronRuby
3118
- * Ruby 1.9.0 and 1.9.1 (but we do recommend against using those)
3119
-
3120
- Not being officially supported means if things only break there and not on a
3121
- supported platform, we assume it's not our issue but theirs.
3122
-
3123
- We also run our CI against ruby-head (future releases of MRI), but we
3124
- can't guarantee anything, since it is constantly moving. Expect upcoming
3125
- 2.x releases to be fully supported.
2830
+ We also keep an eye on upcoming Ruby versions. Expect upcoming
2831
+ 3.x releases to be fully supported.
3126
2832
 
3127
2833
  Sinatra should work on any operating system supported by the chosen Ruby
3128
2834
  implementation.
3129
2835
 
3130
- If you run MacRuby, you should `gem install control_tower`.
3131
-
3132
- Sinatra currently doesn't run on Cardinal, SmallRuby, BlueRuby or any
3133
- Ruby version prior to 2.2.
2836
+ Running Sinatra on a not officially supported Ruby flavor means that if things only break there we assume it's not our issue but theirs.
3134
2837
 
3135
2838
  ## The Bleeding Edge
3136
2839
 
3137
2840
  If you would like to use Sinatra's latest bleeding-edge code, feel free
3138
- to run your application against the master branch, it should be rather
2841
+ to run your application against the main branch, it should be rather
3139
2842
  stable.
3140
2843
 
3141
2844
  We also push out prerelease gems from time to time, so you can do a
@@ -3184,20 +2887,19 @@ SemVerTag.
3184
2887
 
3185
2888
  ## Further Reading
3186
2889
 
3187
- * [Project Website](http://www.sinatrarb.com/) - Additional documentation,
2890
+ * [Project Website](https://sinatrarb.com/) - Additional documentation,
3188
2891
  news, and links to other resources.
3189
- * [Contributing](http://www.sinatrarb.com/contributing) - Find a bug? Need
2892
+ * [Contributing](https://sinatrarb.com/contributing) - Find a bug? Need
3190
2893
  help? Have a patch?
3191
2894
  * [Issue tracker](https://github.com/sinatra/sinatra/issues)
3192
2895
  * [Twitter](https://twitter.com/sinatra)
3193
2896
  * [Mailing List](https://groups.google.com/forum/#!forum/sinatrarb)
3194
2897
  * IRC: [#sinatra](irc://chat.freenode.net/#sinatra) on [Freenode](https://freenode.net)
3195
- * [Sinatra & Friends](https://sinatrarb.slack.com) on Slack
3196
- ([get an invite](https://sinatra-slack.herokuapp.com/))
2898
+ * [Sinatra & Friends](https://discord.gg/ncjsfsNHh7) on Discord
3197
2899
  * [Sinatra Book](https://github.com/sinatra/sinatra-book) - Cookbook Tutorial
3198
2900
  * [Sinatra Recipes](http://recipes.sinatrarb.com/) - Community contributed
3199
2901
  recipes
3200
- * API documentation for the [latest release](http://www.rubydoc.info/gems/sinatra)
3201
- or the [current HEAD](http://www.rubydoc.info/github/sinatra/sinatra) on
3202
- [RubyDoc](http://www.rubydoc.info/)
3203
- * [CI server](https://travis-ci.org/sinatra/sinatra)
2902
+ * API documentation for the [latest release](https://www.rubydoc.info/gems/sinatra)
2903
+ or the [current HEAD](https://www.rubydoc.info/github/sinatra/sinatra) on
2904
+ [RubyDoc](https://www.rubydoc.info/)
2905
+ * [CI Actions](https://github.com/sinatra/sinatra/actions)