Skip to content

Commit

Permalink
updated readme and guides
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianconcept committed Feb 17, 2024
1 parent b9de8ec commit d8de170
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Feb 17, 2024
===================================
- Using by default the same convetion seen in Ruby on Rails.

Jan 23, 2024
===================================
- Added smalltalkCI
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ spec baseline: 'STTemplate' with: [ spec repository: 'github://sebastianconcept/

`STTemplate` is a Smalltalk template class.

It can run Smalltalk code found between the opening (`<st`) and closing (`>`) tags when present in the content.
It can run Smalltalk code found between the opening (`<%`) and closing (`%>`) tags when present in the content.

There are two ways to have Smalltalk running from `STTemplate` instances:

Expand All @@ -60,7 +60,7 @@ There are two ways to have Smalltalk running from `STTemplate` instances:
Analogous to a `printIt`

```smalltalk
'<p><st= ''Hello '', self ></p>' sttRenderOn: 'STT'.
'<p><%= ''Hello '', self %></p>' sttRenderOn: 'STT'.
"'<p>Hello STT</p>'"
```

Expand All @@ -69,10 +69,10 @@ Analogous to a `printIt`
Analogous to a `doIt`

```smalltalk
'<p>Hello STT<st 40+2 ></p>' sttRenderOn: 'STT'.
'<p>Hello STT<% 40+2 %></p>' sttRenderOn: 'STT'.
"'<p>Hello STT</p>'"
'<p>Hello STT<st self crShow: ''Greetings from an STT closure!'' ></p>' sttRenderOn: Transcript.
'<p>Hello STT<% self crShow: ''Greetings from an STT closure!'' %></p>' sttRenderOn: Transcript.
"'<p>Hello STT</p>'"
"And in the Transcript you'll see:"
Expand All @@ -85,15 +85,15 @@ Analogous to a `doIt`
```smalltalk
"Displays the 42 as content of the span element:"
'<p>The Answer: <span><st= 42></span></p>' sttRenderOn: nil.
'<p>The Answer: <span><%= 42%></span></p>' sttRenderOn: nil.
"'<p>The Answer: <span>42</span></p>'"
```

```smalltalk
"Displays the 42 as content of the span element because
adds 2 to the context sent with `sttRenderOn: 40`"
'<p>The Answer: <span><st= self + 2></span></p>' sttRenderOn: 40.
'<p>The Answer: <span><%= self + 2%></span></p>' sttRenderOn: 40.
"'<p>The Answer: <span>42</span></p>'"
```

Expand All @@ -102,7 +102,7 @@ adds 2 to the context sent with `sttRenderOn: 40`"
so it displays `Answer: ` coming from `self key capitalized, ': '`
and then `42` coming from displaying `self value + 2`"
'<p>The <span><st= self key capitalized, '': ''></span><span><st= self value + 2></span></p>' sttRenderOn: (#answer -> 40).
'<p>The <span><%= self key capitalized, '': ''%></span><span><%= self value + 2%></span></p>' sttRenderOn: (#answer -> 40).
"'<p>The <span>Answer: </span><span>42</span></p>'"
```

Expand All @@ -111,7 +111,7 @@ and then `42` coming from displaying `self value + 2`"
In each iteration, it creates another Smalltalk closure that has access
to self as expected and uses that to display its content:"
'<st 1 to: 3 do: [ :i | ><p>The Answer is <span><st= self value + 2>!</span></p><st ] >' sttRenderOn: (#answer -> 40).
'<% 1 to: 3 do: [ :i | %><p>The Answer is <span><%= self value + 2%>!</span></p><% ] >' sttRenderOn: (#answer -> 40).
"'<p>The Answer is <span>42!</span></p><p>The Answer is <span>42!</span></p><p>The Answer is <span>42!</span></p>'"
```

Expand Down
4 changes: 2 additions & 2 deletions tryHtmxBasedCounter.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ sttCounterPage := STTemplate on: '<!DOCTYPE html>
</head>
<body>
<h1>Counter</h1>
<h1 id="counterValue"><st= self></h1>
<h1 id="counterValue"><%= self%></h1>
<button
hx-post="/increase"
hx-target="#counterValue"
Expand All @@ -66,7 +66,7 @@ sttCounterPage := STTemplate on: '<!DOCTYPE html>
</html>'.
"The one for just the part used to update on increase/decrease"
sttCounterView := '<h1 id="counterValue"><st= self></h1>' asSTTemplate.
sttCounterView := '<h1 id="counterValue"><%= self%></h1>' asSTTemplate.
```

### Setup routes
Expand Down
2 changes: 1 addition & 1 deletion tryOnTeapot.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ teapot exception: Error -> [ :ex :req | | content |
teapot GET: '/ping' -> 'pong'.
"Create an SSTemplate"
sstEcho := STTemplate on: '<st [ | echo | echo := self allButFirst ><h1>Echoing:</h1><h2><st= self ></h2><h3><st= echo ></h3><p><st= echo ></p> <st ] value >'.
sstEcho := STTemplate on: '<% [ | echo | echo := self allButFirst %><h1>Echoing:</h1><h2><%= self %></h2><h3><%= echo %></h3><p><%= echo %></p> <% ] value %>'.
"Add a echo route that will render the HTML the template based on the received message value."
teapot GET: '/echo/<message>' -> [ :req | sstEcho renderOn: (req at: #message) ].
Expand Down

0 comments on commit d8de170

Please sign in to comment.