-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experimental support for HTML renderOn methods in dev panel.
- Loading branch information
Showing
9 changed files
with
222 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
" | ||
I am a component that has multiple render methods, which each make up a child component. | ||
This makes it convenient to have separately updatable child components, while keeping the rendering | ||
in the same class. | ||
When initialized, I will create a dictionary of children that map selector to a newly created | ||
LWBlockContainer component. Each child's render must output a single element. | ||
Each child component render method must have an <lwPart> pragma attached. | ||
There is no need to implement children method, it is automatic. | ||
" | ||
Class { | ||
#name : #LWPartsComponent, | ||
#superclass : #LWComponent, | ||
#instVars : [ | ||
'parts' | ||
], | ||
#category : #'LiveWeb-Core' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
Class { | ||
#name : #LWTodoExample, | ||
#superclass : #LWComponent, | ||
#instVars : [ | ||
'items' | ||
], | ||
#category : #'LiveWeb-Examples' | ||
} | ||
|
||
{ #category : #'as yet unclassified' } | ||
LWTodoExample class >> todoExample [ | ||
<lwExample: 'Todo with some items'> | ||
^ self new | ||
item: (LWTodoItem new label: 'create example'; beComplete); | ||
item: (LWTodoItem new label: 'show changing HTML rendering'); | ||
item: (LWTodoItem new label: 'profit!') | ||
] | ||
|
||
{ #category : #initialization } | ||
LWTodoExample >> initialize [ | ||
super initialize. | ||
items := OrderedCollection new. | ||
] | ||
|
||
{ #category : #accessing } | ||
LWTodoExample >> item: aTodoItem [ | ||
items add: aTodoItem. | ||
self changed. | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
LWTodoExample >> itemClass: item [ | ||
^ item complete ifTrue: [ 'complete' ] ifFalse: [ 'incomplete' ] | ||
] | ||
|
||
{ #category : #rendering } | ||
LWTodoExample >> renderOn: h [ | ||
<lwHTML: '<div class="todos"> | ||
<ul> | ||
<li lw:repeat="item items" class="todo {{self itemClass: item}}"> | ||
<input type="checkbox" checked="{{item complete}}"> {{item label}} | ||
</li> | ||
</ul> | ||
todos here</div>'> | ||
h div: { 'class' -> ('todos'). } with: [ h renderContent: (' | ||
'). | ||
h ul: { } with: [ h renderContent: (' | ||
'). | ||
(items) doWithIndex: [ :item :__lw_index | | ||
h li: { 'class' -> (String streamContents: [ :__lw_attr | __lw_attr << ('todo '). __lw_attr << (self itemClass: item). ]). } with: [ h renderContent: (' | ||
'). | ||
h input: { 'checked' -> (item complete). 'type' -> ('checkbox'). }. | ||
h renderContent: (' '). | ||
h renderContent: (item label). | ||
h renderContent: (' | ||
'). | ||
]. | ||
]. | ||
h renderContent: (' | ||
'). | ||
]. | ||
h renderContent: (' | ||
todos here'). | ||
]. | ||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Class { | ||
#name : #LWTodoItem, | ||
#superclass : #Object, | ||
#instVars : [ | ||
'label', | ||
'complete' | ||
], | ||
#category : #'LiveWeb-Examples' | ||
} | ||
|
||
{ #category : #API } | ||
LWTodoItem >> beComplete [ | ||
self complete: true | ||
] | ||
|
||
{ #category : #accessing } | ||
LWTodoItem >> complete [ | ||
|
||
^ complete | ||
] | ||
|
||
{ #category : #accessing } | ||
LWTodoItem >> complete: anObject [ | ||
|
||
complete := anObject | ||
] | ||
|
||
{ #category : #initialization } | ||
LWTodoItem >> initialize [ | ||
super initialize. | ||
complete := false. | ||
|
||
] | ||
|
||
{ #category : #accessing } | ||
LWTodoItem >> label [ | ||
|
||
^ label | ||
] | ||
|
||
{ #category : #accessing } | ||
LWTodoItem >> label: anObject [ | ||
|
||
label := anObject | ||
] |