Changeset 14439 in project


Ignore:
Timestamp:
04/25/09 18:35:10 (11 years ago)
Author:
sjamaan
Message:

Add example to sxml-fu as well

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/sxml-fu

    r14437 r14439  
    129129
    130130Returns the position of the last entry on the page currently being viewed.
     131
     132==== Example
     133
     134<enscript highlight=scheme>
     135;; A quick example of how to use pagination-rules
     136(use sxml-fu sxml-transforms doctype srfi-1)
     137
     138(define my-conversion-rules
     139  `((doctype . ,(lambda (doctype) doctype:xhtml-1.0-strict))
     140    ,@universal-conversion-rules))
     141
     142(define content
     143  `((doctype)
     144    (html
     145     (head
     146      (title "Showing page" ,(current-page 109) " of " ,(page-count 109)))
     147     (body
     148      (paginate-list
     149       (div (@ (class "paginated-stuff"))
     150            (p "Click on a number to flip to the corresponding page:")
     151            (pagination-links)
     152            (p "Below we see something that is shown only once per page "
     153               "(the UL), which has subentries that are shown many times "
     154               "per page, ie the entries on the page (the LIs):")
     155            (ul
     156             (entries
     157              (li (entry))))
     158            (p "As we can see, every part of the page that has to be "
     159               "for every entry is enclosed by the (entries) 'tag'."
     160               "We can also show the same entries twice or more:")
     161            (ol
     162             (entries
     163              (li (entry))))
     164            (p "Showing entry" (first-entry) " through " (last-entry) " on "
     165               "page " (current-page) " of " (page-count) "."))
     166       ,(iota 109))
     167      (p "We are showing entry " ,(first-entry 109) " through "
     168         ,(last-entry 109) ".")
     169      (p "Note that it is necessary to pass the total number of entries "
     170         "to every pagination function, but not the actual tags within "
     171         "(pagination).  This is because the paginator has no way of "
     172         "determining this outside of the (paginate-list) 'tag'.")))))
     173
     174(define (output-html content . rules)
     175  (SRV:send-reply (fold (lambda (ruleset content)
     176                          (pre-post-order content ruleset)) content rules)))
     177
     178(output-html content pagination-rules shortcut-rules my-conversion-rules)
     179</enscript>
    131180
    132181=== sxml-shortcuts
Note: See TracChangeset for help on using the changeset viewer.