-
-
Save jeffrydegrande/3422437 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
; a quick attempt at doing the same thing in clojure could for example something like | |
(defpartial input [name] | |
[:tr | |
[:td | |
[:input {:name name}]]]) | |
(defpartial edit-task-form [& inputs] | |
[:div.generic.lightbox | |
[:table | |
(map input inputs) | |
[:tr | |
[:td | |
[:input {:type :submit :name :submit}]]] | |
]]) | |
; which will let you call it like | |
(edit-task-form :name :description :date :completed) | |
; this is not pretty and not something you want a designer to have to work in, but ... it has a few useful properties, ; ; ; Since it's just data, you can manipulate in a simple straightforward way, like mapping over stuff to build that list | |
; of inputs | |
; more useful though is composability .. I can do something like: | |
(defpartial layout & content] | |
[:body | |
[:div#wrapper | |
content]])) | |
; which allows me to put pages together like | |
(layout | |
(edit-task-form :name :age)) | |
(layout | |
(edit-something-else-form :name :age)) | |
; This will not help at all with design in the early stages... | |
; but it will help with maintaining stable markup as the application grows. | |
; from a programmers point of view I can see real benefits whereas the smalltalk example I can not. |
This file contains hidden or 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
renderContentOn: html | |
html div | |
class: 'generic lightbox'; | |
with: [ | |
html heading: 'Editing task'. | |
html form: [ | |
html table: [ | |
html | |
tableRow: [self renderNameInputOn: html]; | |
tableRow: [self renderDescriptionInputOn: html]; | |
tableRow: [self renderDateInputOn: html]; | |
tableRow: [self renderCompletedSelectionOn: html]; | |
tableRow: [self renderButtonsOn: html]]]]. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment