Skip to content

Instantly share code, notes, and snippets.

@jeffrydegrande
Forked from anonymous/gist:3422266
Created August 22, 2012 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffrydegrande/3422437 to your computer and use it in GitHub Desktop.
Save jeffrydegrande/3422437 to your computer and use it in GitHub Desktop.
; 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.
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