Skip to content

Commit 98593e2

Browse files
committed
Helpers and configure methods added
1 parent d10afd1 commit 98593e2

File tree

7 files changed

+64
-3
lines changed

7 files changed

+64
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.5.1] - 2021-07-26
2+
3+
- `helpers` and `configure` methods added
4+
15
## [0.5.0] - 2021-07-25
26

37
- Templates rendering added

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
yaframework (0.5.0)
4+
yaframework (0.5.1)
55
rack (~> 2.2, >= 2.2.3)
66
tilt (~> 2.0)
77

examples/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,20 @@ Here are some examples of applications created with Yaframework:
4242
How to use `before` and `after` hooks
4343

4444

45-
8. [**Rendering**](https://github.com/maxbarsukov/yaframework/tree/master/examples/rendering)
45+
9. [**Rendering**](https://github.com/maxbarsukov/yaframework/tree/master/examples/rendering)
4646

4747
Rendering your `.erb` (or any else) files and partials using tilt.
4848

4949

50+
10. [**Helpers**](https://github.com/maxbarsukov/yaframework/blob/master/examples/helpers.rb)
51+
52+
Example of using helpers
53+
54+
55+
11. [**Configure**](https://github.com/maxbarsukov/yaframework/blob/master/examples/configure.rb)
56+
57+
How to configure your application
58+
5059
## Installation
5160

5261
Clone this repo and go to this folder.

examples/configure.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
require "yaframework"
4+
app = Yaframework::Application
5+
6+
app.configure do
7+
@app_name
8+
end
9+
10+
app.get "/" do
11+
"Hey, that's #{@app_name}"
12+
end
13+
14+
app.listen(9292)

examples/helpers.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
require "yaframework"
4+
app = Yaframework::Application
5+
6+
app.helpers do
7+
def hello
8+
"Hello"
9+
end
10+
11+
def colon
12+
", "
13+
end
14+
end
15+
16+
app.helpers do
17+
def world
18+
"world!"
19+
end
20+
end
21+
22+
app.get "/" do
23+
hello + colon + world
24+
end
25+
26+
app.listen(9292)

lib/yaframework/base.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ def initialize
2525
end
2626
end
2727

28+
def helpers(&block)
29+
exec(block) if block_given?
30+
end
31+
32+
def configure(&block)
33+
exec(block) if block_given?
34+
end
35+
2836
def call(env)
2937
@env = env
3038
@request = Yaframework::Request.new @env

lib/yaframework/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Yaframework
4-
VERSION = "0.5.0"
4+
VERSION = "0.5.1"
55
end

0 commit comments

Comments
 (0)