Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Start of Lift 2.0 work (attribute handling)

Closes #5

Made a minor fix and decided to go ahead and start working
on the Lift 2.0 changes. The first change is a reorg and
revision of how Lift handles attributes on elements. Moved all
relevant sections to chapter 3 (fundamentals), revised attribute
binding to talk about the "-%>" operator, and made a subsection
in the forms chapter about using the varargs params on SHtml.*
to simplify attribute handling.
  • Loading branch information...
commit fd6256e768276ff81ee80f0116330ef957c95831 1 parent 283da72
@dchenbecker dchenbecker authored
Showing with 749 additions and 241 deletions.
  1. +187 −185 chap-advanced.lyx
  2. +120 −52 chap-forms.lyx
  3. +439 −2 chap-lift_architecture.lyx
  4. +3 −2 master.lyx
View
372 chap-advanced.lyx
@@ -1,4 +1,4 @@
-#LyX 1.6.4 created this file. For more info see http://www.lyx.org/
+#LyX 1.6.5 created this file. For more info see http://www.lyx.org/
\lyxformat 345
\begin_document
\begin_header
@@ -2631,27 +2631,66 @@ This feature allows you use a resource before Lift does and release them
\end_layout
\begin_layout Subsection
-Additional Snippet Features
-\begin_inset CommandInset label
-LatexCommand label
-name "sub:Additional-Snippet-Features"
+Passing Template Parameters to Snippets
+\begin_inset Index
+status open
+
+\begin_layout Plain Layout
+Parameters
+\end_layout
\end_inset
+\begin_inset Index
+status open
+
+\begin_layout Plain Layout
+Snippet parameters
\end_layout
-\begin_layout Standard
-By now you already have a fairly good idea how snippets work, how you can
- use them etc.
- There are a few things that were not revealed yet to you, such as:
+\end_inset
+
+
\end_layout
-\begin_layout Enumerate
-Ability to pass parameters to snippets:
+\begin_layout Standard
+In addition to the standard attributes for snippets, outlined in Section
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "sub:snippet-tag"
+
+\end_inset
+
+, you can set your own attributes on the snippet element.
+ Attributes used in this manner are called
+\begin_inset Quotes eld
+\end_inset
+
+parameters
+\begin_inset Quotes erd
+\end_inset
+
+.
+ Listing
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "lst:Snippet-parameter-template"
+
+\end_inset
+
+ shows us setting a
+\family typewriter
+default
+\family default
+ parameter on our
+\family typewriter
+Ledger.balance
+\family default
+ snippet.
\end_layout
-\begin_deeper
\begin_layout Standard
\begin_inset listings
inline false
@@ -2662,7 +2701,13 @@ status open
\begin_inset Caption
\begin_layout Plain Layout
-Snippet attributes
+\begin_inset CommandInset label
+LatexCommand label
+name "lst:Snippet-parameter-template"
+
+\end_inset
+
+Defining a Snippet Parameter
\end_layout
\end_inset
@@ -2691,12 +2736,19 @@ Snippet attributes
\end_layout
\begin_layout Standard
-How do we read the
-\emph on
-default
-\emph default
- attribute from the snippet code? Actualy it is only about calling S.attr
- function.
+The
+\family typewriter
+S.attr
+\family default
+ function allows us to access all parameters defined on the snippet element
+ itself, as shown in Listing
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "lst:Snippet-parameter-code"
+
+\end_inset
+
+.
\end_layout
\begin_layout Standard
@@ -2709,7 +2761,13 @@ status open
\begin_inset Caption
\begin_layout Plain Layout
-Snippet attributes
+\begin_inset CommandInset label
+LatexCommand label
+name "lst:Snippet-parameter-code"
+
+\end_inset
+
+Accessing a Snippet Parameter
\end_layout
\end_inset
@@ -2729,7 +2787,7 @@ class Ledger {
\begin_layout Plain Layout
- val dflt = S.attr("default") openOr "0";
+ val dflt = S.attr("default") openOr "0";
\end_layout
\begin_layout Plain Layout
@@ -2766,68 +2824,13 @@ class Ledger {
\end_layout
-\end_deeper
-\begin_layout Enumerate
-Use snippets for tag attributes:
-\end_layout
-
-\begin_deeper
-\begin_layout Standard
-\begin_inset listings
-inline false
-status open
-
-\begin_layout Plain Layout
-
-\begin_inset Caption
-
-\begin_layout Plain Layout
-Attribute Snippet
-\end_layout
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Plain Layout
-
-// In your page you can have
-\end_layout
-
-\begin_layout Plain Layout
-
-<div lift:snippet="MyDivThing:calcDir"> ...
- </div>
-\end_layout
-
-\begin_layout Plain Layout
-
-\end_layout
-
-\begin_layout Plain Layout
-
-...
-\end_layout
-
-\begin_layout Plain Layout
-
-// Your snippet
-\end_layout
-
-\begin_layout Plain Layout
-
-class MyDivThing {
-\end_layout
-
-\begin_layout Plain Layout
-
- def calcDir = new UnprefixedAttribute("dir", "rtl", Null)
-\end_layout
+\begin_layout Subsection
+Computing Attributes with Snippets
+\begin_inset Index
+status collapsed
\begin_layout Plain Layout
-
-}
+Attributes ! computing via snippet
\end_layout
\end_inset
@@ -2836,33 +2839,14 @@ class MyDivThing {
\end_layout
\begin_layout Standard
-The utility of this support is quite obvious in so many situations.
- For instance when supporting right-to-left languages you can add the direction
- of the page to be rtl quite easily.
-\end_layout
-
-\end_deeper
-\begin_layout Standard
-Now we have seen how we can pass xml parameters to snippets but what if
- we want to pass parameters to the nodes that will be bound? For instance
- in Listing 1.3 we also want to pass the am/pm information:
-\end_layout
-
-\begin_layout Standard
-
-\family typewriter
-<ledger:time ampm=
-\begin_inset Quotes erd
-\end_inset
+You can use snippets to compute tag attributes, as shown in Listing
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "lst:Using-a-Snippet-compute-attr"
-true
-\begin_inset Quotes erd
\end_inset
-/>
-\family default
-where the time will be displayed in AM-PM format as opposed to 24h format.
- But how can we access the ampm parameter?
+:
\end_layout
\begin_layout Standard
@@ -2875,14 +2859,13 @@ status open
\begin_inset Caption
\begin_layout Plain Layout
-Snippet attributes
\begin_inset CommandInset label
LatexCommand label
-name "lst:Snippet-attributes"
+name "lst:Using-a-Snippet-compute-attr"
\end_inset
-
+Using a Snippet to Compute an Attribute
\end_layout
\end_inset
@@ -2892,95 +2875,97 @@ name "lst:Snippet-attributes"
\begin_layout Plain Layout
-class Ledger {
+// In your page you can have
\end_layout
\begin_layout Plain Layout
- def balance (content : NodeSeq ) : NodeSeq = {
+<div lift:snippet="MyDivThing:calcDir"> ...
+ </div>
\end_layout
\begin_layout Plain Layout
- val dflt = S.attr("default") openOr "0";
\end_layout
\begin_layout Plain Layout
- bind ("ledger", content,
+...
\end_layout
\begin_layout Plain Layout
- "balance" -> Text(currentLegdger.formattedBalance),
+// Your snippet
\end_layout
\begin_layout Plain Layout
- "time" -> {node: NodeSeq => println(BindHelpers.attr("ampm"));
- Text((new java.util.Date).toString))}
+class MyDivThing {
\end_layout
\begin_layout Plain Layout
- }
+ def calcDir = new UnprefixedAttribute("dir", "rtl", Null)
\end_layout
\begin_layout Plain Layout
-}
+}
\end_layout
-\begin_layout Plain Layout
+\end_inset
+
\end_layout
+\begin_layout Subsection
+Processing Element Attributes
+\begin_inset Index
+status open
+
+\begin_layout Plain Layout
+Attributes ! retrieving from elements
+\end_layout
+
\end_inset
\end_layout
\begin_layout Standard
-The key aspect here is the BindHelpers object.
- You can use it for obtaining information about node attributes.
- This context is maintained internally using ThreadLocals and closures.
- Note that the context is cleared after bind method is executed.
- In our example above for
-\begin_inset Quotes eld
+Now we have seen how we can pass xml parameters to snippets but what if
+ we want to pass parameters on the nodes that will be bound? For instance,
+ we may want to pass the am/pm information on the time element such as:
+\end_layout
+
+\begin_layout LyX-Code
+
+\family typewriter
+<ledger:time ampm=
+\begin_inset Quotes erd
\end_inset
-time
+true
\begin_inset Quotes erd
\end_inset
- node we are actually binding a function that takes the child nodes of the
-
-\family typewriter
-<ledger:time>
-\family default
- node.
- When our function is called by Lift we can access the BindHelpers, such
- ass the attributes of the current node.
- The sequence
-\family typewriter
-<string> -> <right-hand-side-expression>
-\family default
- is turned into a BindParam object using implicit conversions.
- It is important to note that BindParam.calcValue function is called in the
- correct context so that BindHelpers can be safely used.
+/>
\end_layout
\begin_layout Standard
-It is sometimes more convenient to just put node attributes in the markup
- and just not worry about them in the Scala code.
- Consider Listing
+to control the time display format.
+ Listing
\begin_inset CommandInset ref
LatexCommand ref
-reference "lst:Snippet-mixin-attributes"
+reference "lst:Element-attribute-retrieval"
\end_inset
-:
+ shows how we can use the
+\family typewriter
+BindHelpers
+\family default
+ object to retrieve the current element's attributes.
\end_layout
\begin_layout Standard
@@ -2993,10 +2978,10 @@ status open
\begin_inset Caption
\begin_layout Plain Layout
-Snippet mixin attributes
+Retrieving Element Attributes with BindHelpers
\begin_inset CommandInset label
LatexCommand label
-name "lst:Snippet-mixin-attributes"
+name "lst:Element-attribute-retrieval"
\end_inset
@@ -3010,107 +2995,120 @@ name "lst:Snippet-mixin-attributes"
\begin_layout Plain Layout
-// the markup
+class Ledger {
\end_layout
\begin_layout Plain Layout
-<lift:Ledger.balance>
+ def balance (content : NodeSeq ) : NodeSeq = {
\end_layout
\begin_layout Plain Layout
- <ledger:time ledger:id="myId"/>
+ val dflt = S.attr("default") openOr "0";
\end_layout
\begin_layout Plain Layout
-</lift:Ledger.balance>
+ bind ("ledger", content,
\end_layout
\begin_layout Plain Layout
+ "balance" -> Text(currentLegdger.formattedBalance),
\end_layout
\begin_layout Plain Layout
-// The snippet class
+ "time" -> {
\end_layout
\begin_layout Plain Layout
+ node: NodeSeq => println(BindHelpers.attr("ampm"));
\end_layout
\begin_layout Plain Layout
-class Ledger {
+ Text((new java.util.Date).toString))
\end_layout
\begin_layout Plain Layout
- def balance (content : NodeSeq ) : NodeSeq = {
+ })
\end_layout
\begin_layout Plain Layout
- bind ("ledger", content,
+ }
\end_layout
\begin_layout Plain Layout
- "time" -> <span>{(new java.util.Date).toString}</span>)
+}
\end_layout
\begin_layout Plain Layout
- }
\end_layout
-\begin_layout Plain Layout
+\end_inset
+
-}
\end_layout
+\begin_layout Standard
+\begin_inset Note Note
+status open
+
+\begin_layout Plain Layout
+Is that
+\begin_inset Quotes eld
\end_inset
+node:NodeSeq
+\begin_inset Quotes erd
+\end_inset
+ necessary?
\end_layout
-\begin_layout Standard
-Now what we just did was to prefix the
+\end_inset
+
+You can use the
\family typewriter
-id
+BindHelpers
\family default
- attribute for the time node.
- Lift will automatically add the attributes preffixed with the same node
- preffix to the resulting bind element for
+ object for obtaining information about node attributes.
+ This context is maintained internally using
\family typewriter
-time
+ThreadLocal
\family default
-.
- Thefore the resulting node will be something like
-\family typewriter
-<span id=
-\begin_inset Quotes erd
+s and closures.
+ Note that the context is cleared after the bind method is executed.
+ In our example above for
+\begin_inset Quotes eld
\end_inset
-myId
+time
\begin_inset Quotes erd
\end_inset
->Sat Mar 28 16:43:48 EET 2009</span>
+ node we are actually binding a function that takes the child nodes of the
+
+\family typewriter
+<ledger:time>
\family default
-
-\begin_inset Note Note
-status open
-
-\begin_layout Plain Layout
-Is this still valid in 1.1?
-\end_layout
-
-\end_inset
-
-.
+ node.
+ When our function is called by Lift we can access the BindHelpers, such
+ ass the attributes of the current node.
+ The sequence
+\family typewriter
+<string> -> <right-hand-side-expression>
+\family default
+ is turned into a BindParam object using implicit conversions.
+ It is important to note that BindParam.calcValue function is called in the
+ correct context so that BindHelpers can be safely used.
\end_layout
\begin_layout Section
@@ -3208,7 +3206,11 @@ The
\family typewriter
S.timeZone
\family default
- function returns the current timezone as computed by the
+ function returns the current timezone as computed by the
+\begin_inset Newline linebreak
+\end_inset
+
+
\family typewriter
LiftRules.timeZoneCalculator
\family default
View
172 chap-forms.lyx
@@ -1,4 +1,4 @@
-#LyX 1.6.3 created this file. For more info see http://www.lyx.org/
+#LyX 1.6.5 created this file. For more info see http://www.lyx.org/
\lyxformat 345
\begin_document
\begin_header
@@ -166,7 +166,7 @@ name "lst:An-example-form-template"
\begin_layout Plain Layout
- <entry:description /> <entry.amount /><br />
+ <entry:description /> <entry:amount /><br />
\end_layout
\begin_layout Plain Layout
@@ -616,6 +616,118 @@ processEntryAdd
\family default
function, which, having access to the variables we've defined, can do whatever
it needs to do when the submit button is pressed.
+
+\end_layout
+
+\begin_layout Section
+\begin_inset CommandInset label
+LatexCommand label
+name "sec:Attributes-for-Form-Elems"
+
+\end_inset
+
+Attributes for Form Elements
+\begin_inset Index
+status open
+
+\begin_layout Plain Layout
+Attributes ! in form elements
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+In addition to the approaches shown in Section
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "sec:Handling-XHTML-Attributes"
+
+\end_inset
+
+, the SHtml generator functions allow you to apply attributes by passing
+ the attribute name/value pairs as final arguments.
+ This is usually simpler, and in some cases is much simpler than using the
+
+\begin_inset Quotes eld
+\end_inset
+
+%
+\begin_inset Quotes erd
+\end_inset
+
+ operator directly.
+ For example, checkbox and radio form elements are acutally returned as
+ ChoiceHolder instances, which do not directly support the
+\begin_inset Quotes eld
+\end_inset
+
+%
+\begin_inset Quotes erd
+\end_inset
+
+ operator.
+ Listing
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "lst:Applying-Attributes-vararg"
+
+\end_inset
+
+ shows how to apply the same attributes as Listing
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "lst:Applying-Attributes-percent"
+
+\end_inset
+
+ using the varargs approach.
+\end_layout
+
+\begin_layout Standard
+\begin_inset listings
+inline false
+status open
+
+\begin_layout Plain Layout
+
+val myInput = SHtml.text("", processText(_), "id" -> "inputField",
+\end_layout
+
+\begin_layout Plain Layout
+
+ "class" -> "highlighted")
+\end_layout
+
+\begin_layout Plain Layout
+
+\begin_inset Caption
+
+\begin_layout Plain Layout
+
+\begin_inset CommandInset label
+LatexCommand label
+name "lst:Applying-Attributes-vararg"
+
+\end_inset
+
+Applying Attributes as Varargs
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+An Overview of Form Elements
\end_layout
\begin_layout Standard
@@ -692,61 +804,17 @@ an unchecked checkbox is not actually submitted as part of a form
Lift works around this by adding a hidden form element for each checkbox
with the same element name, but with a false value, to ensure that the
callback function is always called.
-
-\end_layout
-
-\begin_layout Standard
-Both overloads for checkbox take a final varargs sequence of
-\family typewriter
-Pair(String,String)
-\family default
- so that you can provide any XML attributes that you'd like to have on the
- checkbox element.
Because more than one XML node is returned by the generator, you can’t
- just use the % metadata mechanism to set attributes on the check box element.
-
-\end_layout
-
-\begin_layout Standard
-\align center
-\begin_inset Box Shadowbox
-position "t"
-hor_pos "c"
-has_inner_box 1
-inner_pos "t"
-use_parbox 0
-width "75col%"
-special "none"
-height "1in"
-height_special "totalheight"
-status open
-
-\begin_layout Plain Layout
-Note The % metadata mechanism is actually part of the Scala XML library.
- Specifically,
-\family typewriter
-scala.xml.Elem
-\family default
- has a
-\family typewriter
-%
-\family default
- method that allows the user to update the attributes on a given XML element.
- We suggest reading more about this in the Scala API documents, or in the
- Scala XML docbook at
-\begin_inset CommandInset href
-LatexCommand href
-target "http://burak.emir.googlepages.com/scalaxbook.docbk.html"
+ use the % metadata mechanism to set attributes on the check box element.
+ Instead, use attribute pairs as arguments to the generator function as
+ outlined in Section
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "sub:Direct-Manipulation-in"
\end_inset
.
-
-\end_layout
-
-\end_inset
-
-
\end_layout
\begin_layout Standard
View
441 chap-lift_architecture.lyx
@@ -1,4 +1,4 @@
-#LyX 1.6.3 created this file. For more info see http://www.lyx.org/
+#LyX 1.6.5 created this file. For more info see http://www.lyx.org/
\lyxformat 345
\begin_document
\begin_header
@@ -1367,7 +1367,17 @@ A.snippet
\family typewriter
A.snippet
\family default
- method we bind, or replace, the
+ method we bind
+\begin_inset Index
+status open
+
+\begin_layout Plain Layout
+bind
+\end_layout
+
+\end_inset
+
+, or replace, the
\family typewriter
<A:name />
\family default
@@ -3674,6 +3684,38 @@ As you can see here, we actually gain a line of code over our previous effort,
by editing the template.
\end_layout
+\begin_layout Standard
+One last aspect of binding that we want to discuss is that any attributes
+ set on the input elements that are being bound will be discarded
+\begin_inset Index
+status open
+
+\begin_layout Plain Layout
+Attributes ! discarded in bind
+\end_layout
+
+\end_inset
+
+ if you use the
+\begin_inset Quotes eld
+\end_inset
+
+->
+\begin_inset Quotes erd
+\end_inset
+
+ binding operator.
+ See Section
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "sec:Handling-XHTML-Attributes"
+
+\end_inset
+
+ for more details on how you manipulate attributes in bindings, including
+ how you can retain attributes on binding elements from your templates.
+\end_layout
+
\begin_layout Subsection
Stateless versus Stateful Snippets
\begin_inset CommandInset label
@@ -4517,6 +4559,401 @@ Add example of same snippet on multiple pages.
\end_layout
\begin_layout Section
+\begin_inset CommandInset label
+LatexCommand label
+name "sec:Handling-XHTML-Attributes"
+
+\end_inset
+
+Handling XHTML Attributes
+\begin_inset Index
+status open
+
+\begin_layout Plain Layout
+Attributes
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+It's a common requirement that elements contain XHTML attributes to control
+ things like style, provide an id, register javascript event handlers, and
+ other functionality.
+ Lift provides two main approaches to applying attributes to elements either
+ in your Scala code or directly in the XHTML template.
+\end_layout
+
+\begin_layout Subsection
+\begin_inset CommandInset label
+LatexCommand label
+name "sub:Direct-attr-manip"
+
+\end_inset
+
+Direct Manipulation in Code
+\end_layout
+
+\begin_layout Standard
+You can apply attributes directly to XHTML elements using the
+\begin_inset Quotes eld
+\end_inset
+
+%
+\begin_inset Quotes erd
+\end_inset
+
+ operator
+\begin_inset Index
+status open
+
+\begin_layout Plain Layout
+Attributes ! % operator
+\end_layout
+
+\end_inset
+
+ to apply a
+\begin_inset Newline linebreak
+\end_inset
+
+
+\family typewriter
+scala.xml.UnprefixedAttribute
+\family default
+ instance
+\begin_inset Foot
+status open
+
+\begin_layout Plain Layout
+there's a corresponding
+\family typewriter
+PrefixedAttribute
+\family default
+ as well
+\end_layout
+
+\end_inset
+
+ to an element.
+ Lift's
+\family typewriter
+net.liftweb.util.Helpers
+\family default
+ trait contains an implicit conversion from a
+\family typewriter
+Pair[String,_]
+\family default
+ to an
+\family typewriter
+UnprefixedAttribute
+\family default
+ called
+\family typewriter
+pairToUnprefixed
+\family default
+ that allows you to use a simpler syntax.
+ You may chain invocations of
+\begin_inset Quotes eld
+\end_inset
+
+%
+\begin_inset Quotes erd
+\end_inset
+
+ to apply multiple attributes.
+ For example, Listing
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "lst:Applying-Attributes-percent"
+
+\end_inset
+
+ shows how you can apply an
+\begin_inset Quotes eld
+\end_inset
+
+id
+\begin_inset Quotes erd
+\end_inset
+
+ and
+\begin_inset Quotes eld
+\end_inset
+
+class
+\begin_inset Quotes erd
+\end_inset
+
+ attribute to a text box and to a normal paragraph.
+\end_layout
+
+\begin_layout Standard
+\begin_inset listings
+inline false
+status open
+
+\begin_layout Plain Layout
+
+val myInput = SHtml.text("", processText(_)) % ("id" -> "inputField") %
+\end_layout
+
+\begin_layout Plain Layout
+
+ ("class" -> "highlighted")
+\end_layout
+
+\begin_layout Plain Layout
+
+\begin_inset Caption
+
+\begin_layout Plain Layout
+\begin_inset CommandInset label
+LatexCommand label
+name "lst:Applying-Attributes-percent"
+
+\end_inset
+
+Applying Attributes with
+\family typewriter
+%
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Box Shadowbox
+position "t"
+hor_pos "c"
+has_inner_box 1
+inner_pos "t"
+use_parbox 0
+width "75col%"
+special "none"
+height "1in"
+height_special "totalheight"
+status open
+
+\begin_layout Plain Layout
+Note that the % metadata mechanism is actually part of the Scala XML library.
+ Specifically,
+\family typewriter
+scala.xml.Elem
+\family default
+ has a
+\family typewriter
+%
+\family default
+ method that allows the user to update the attributes on a given XML element
+ by passing in a
+\family typewriter
+scala.xml.UnprefixedAttribute
+\family default
+.
+ We suggest reading more about this in the Scala API documents, or in the
+ Scala XML docbook at
+\begin_inset CommandInset href
+LatexCommand href
+target "http://burak.emir.googlepages.com/scalaxbook.docbk.html"
+
+\end_inset
+
+.
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+\begin_inset CommandInset label
+LatexCommand label
+name "sub:XHTML-Attribute-Pass-through"
+
+\end_inset
+
+XHTML Attribute Pass-through
+\begin_inset Index
+status open
+
+\begin_layout Plain Layout
+Attributes ! binding
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+The second main approach to modifying XHTML attributes is to specify them
+ directly in your templates.
+ This has the benefit of allowing your template designers to directly manipulate
+ things like style-related attributes and keeping the markup and the logic
+ separate.
+ Listing
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "lst:Snippet-mixin-attributes"
+
+\end_inset
+
+ shows how you can utilize the
+\begin_inset Quotes eld
+\end_inset
+
+-%>
+\begin_inset Quotes erd
+\end_inset
+
+
+\begin_inset Index
+status open
+
+\begin_layout Plain Layout
+Attributes ! -%> operator
+\end_layout
+
+\end_inset
+
+ binding operator instead of
+\begin_inset Quotes eld
+\end_inset
+
+->
+\begin_inset Quotes erd
+\end_inset
+
+ to preserve attributes.
+ Note that you need to prefix attributes that you want to retain with the
+ same prefix as the element in which they're defined.
+\end_layout
+
+\begin_layout Standard
+\begin_inset listings
+inline false
+status open
+
+\begin_layout Plain Layout
+
+\begin_inset Caption
+
+\begin_layout Plain Layout
+Snippet mixin attributes
+\begin_inset CommandInset label
+LatexCommand label
+name "lst:Snippet-mixin-attributes"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+
+// the markup
+\end_layout
+
+\begin_layout Plain Layout
+
+<lift:Ledger.balance>
+\end_layout
+
+\begin_layout Plain Layout
+
+ <ledger:time ledger:id="myId"/>
+\end_layout
+
+\begin_layout Plain Layout
+
+</lift:Ledger.balance>
+\end_layout
+
+\begin_layout Plain Layout
+
+\end_layout
+
+\begin_layout Plain Layout
+
+// The snippet class
+\end_layout
+
+\begin_layout Plain Layout
+
+\end_layout
+
+\begin_layout Plain Layout
+
+class Ledger {
+\end_layout
+
+\begin_layout Plain Layout
+
+ def balance (content : NodeSeq ) : NodeSeq = {
+\end_layout
+
+\begin_layout Plain Layout
+
+ bind ("ledger", content,
+\end_layout
+
+\begin_layout Plain Layout
+
+ "time" -%> <span>{(new java.util.Date).toString}</span>)
+\end_layout
+
+\begin_layout Plain Layout
+
+ }
+\end_layout
+
+\begin_layout Plain Layout
+
+}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+The resulting node will be something like
+\end_layout
+
+\begin_layout LyX-Code
+
+\family typewriter
+<span id=
+\begin_inset Quotes erd
+\end_inset
+
+myId
+\begin_inset Quotes erd
+\end_inset
+
+>Sat Mar 28 16:43:48 EET 2009</span>
+\end_layout
+
+\begin_layout Section
URL Rewriting
\begin_inset CommandInset label
LatexCommand label
View
5 master.lyx
@@ -1,4 +1,4 @@
-#LyX 1.6.2 created this file. For more info see http://www.lyx.org/
+#LyX 1.6.5 created this file. For more info see http://www.lyx.org/
\lyxformat 345
\begin_document
\begin_header
@@ -121,7 +121,8 @@ Derek Chen-Becker, Marius Danciu and Tyler Weir
\begin_layout Standard
\noindent
-Copyright © 2008, 2009 by Derek Chen-Becker, Marius Danciu, and Tyler Weir.
+Copyright © 2008, 2009, 2010 by Derek Chen-Becker, Marius Danciu, David
+ Pollak, and Tyler Weir.
\begin_inset Newline newline
\end_inset
Please sign in to comment.
Something went wrong with that request. Please try again.