Skip to content

Commit

Permalink
Merge 607ae9b
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianconcept committed Feb 18, 2024
2 parents 01029d4 + 607ae9b commit 172ac8c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 4 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Feb 17, 2024
Jan 25, 2024
===================================
- Using by default the same convetion seen in Ruby on Rails.
- STT has new deprecated methods in favor of methods that are friendlier to Ride-based applications.
- `STT yield: aNamedPartialToYield` is now `STT yieldUsing: aNamedPartialToYield`.
- `STT yield: aNamedPartialToYield on: aContext` is now `STT yield: aContext using: aNamedPartialToYield`.

Jan 23, 2024
===================================
Expand Down
14 changes: 14 additions & 0 deletions STTemplate/STT.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,17 @@ STT class >> yieldPartial: anSTTemplate on: aContext [
result := anSTTemplate renderOn: aContext.
outStream nextPutAll: result
]

{ #category : #public }
STT class >> yieldUsing: aNamedPartialToYield [

| renderingContext |
renderingContext := STTCurrentRenderingContext value.
renderingContext ifNil: [
STTError signal:
('Template context unreacheable while trying to yield {1}' format:
{ aNamedPartialToYield asString }) ].
self
yield: renderingContext templateContext
using: aNamedPartialToYield
]
6 changes: 4 additions & 2 deletions STTemplate/STTemplate.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ STTemplate >> isToBeDisplayed: sourceStream displayToken: displayToken [
STTemplate >> isUnnamedYield: aSmalltalkExpression [

^ (aSmalltalkExpression indexOfSubCollection: 'yield') > 0 and: [
(aSmalltalkExpression indexOfSubCollection: 'yield:') isZero ]
(aSmalltalkExpression indexOfSubCollection: 'yieldUsing:') isZero ]
]

{ #category : #actions }
Expand Down Expand Up @@ -369,6 +369,7 @@ STTemplate >> render [
STTemplate >> renderNamedYieldsFrom: smalltalkExpression on: rendered [

| partialRenderingSnippet |

partialRenderingSnippet := String streamContents: [ :str |
str nextPutAll: smalltalkExpression.
self
Expand Down Expand Up @@ -498,7 +499,8 @@ STTemplate >> renderYieldOn: rendered [
| partialRenderingSnippet smalltalkExpression |
"Preserves the context in which the partial should be rendered
and makes it available by grabbing it from the expected private selector key."
smalltalkExpression := 'STT yield: #_yield on: self'.

smalltalkExpression := 'STT yieldUsing: #_yield'.

partialRenderingSnippet := String streamContents: [ :str |
str nextPutAll: smalltalkExpression.
Expand Down

0 comments on commit 172ac8c

Please sign in to comment.