Changes between Version 4 and Version 5 of Ticket #1580
- Mar 13, 2010 8:57:21 AM (4 years ago)
v4 v5 1 2 3 4 5 6 1 7 Almost all web applications need to generate HTML for rendering in the user's browser. The three perhaps most important properties in an HTML generation library are: 2 8 3 9 * High performance: Given that the network introduces a lot of latency the server is left with very little time to create a response to send back to the client. Every millisecond not spent on generating HTML can be used to process the user's request. Furthermore, efficient use of the server's resources is important to keep the number of clients per server high and costs per client low. 4 10 5 11 * Correctness: Incorrectly created HTML can result in anything from incorrect rendering (in the best case) to XSS attacks (in the worst case). 6 12 7 13 * Composability: Being able to create small widgets and reuse them on several pages fosters consistency in the generated output and helps both correctness and reuse. (Being able to treat HTML fragments as values rather than as strings is important.) 8 14 9 15 Combinator libraries, like the [http://hackage.haskell.org/package/html html package] on Hackage, address the the last two criteria by making the generated HTML correct by construction and making HTML fragments first class values. Traditional templating systems generally have the first property, offering excellent performance, but lacks the other two. … … 15 21 = Non-Goals = 16 22 17 23 * Using the very latest type system features to ensure well-formedness. This is not a research project; The goal is to create a production quality library using know techniques. 18 24 19 25 * Integrating with [http://hackage.haskell.org/package/formlets formlets]. 20 26 21 27 = Tasks = 22 28 23 29 1. Write an initial implementation based on the API in `Text.Html` (skip `Text.Html.BlockTable`) but with an more predictable naming scheme for combinators. For example, all combinators should have the same name as their HTML counterparts except when they collide with reserved words in which case an "_" is appended. 24 30 25 31 Move the attribute combinators into `Text.Html.Attribute` and use namespaces instead of function prefixes to resolve name collisions. 26 32 27 33 2. Write a test suite and a benchmark suite. 28 34 29 35 3. With the support of the test and benchmark suite, optimize the performance of the library. Perhaps using tools like [http://hackage.haskell.org/package/ghc-core ghc-core] to study the generated code. 30 36 31 37 4. Document the API extensively, using Haddock. Include usage examples at the top of the module. 32 38 33 39 = Tools = 34 40 35 36 37 41 * [http://hackage.haskell.org/package/quickcheck QuickCheck] for testing, 42 * [http://hackage.haskell.org/package/criterion Criterion] for benchmarking, and 43 * [http://hackage.haskell.org/package/haddock Haddock] for documenting. 38 44 39 45 = Interested Mentors = 40 46 41 * Johan Tibell 47 * Johan Tibell 48 49 = FAQ = 50 51 * Q: Why not use a templating language? 52 53 * A: While popular, templating languages suffer from a number of problems: 54 * Lack of abstraction features to address code and HTML duplication. Templating languages tend to become (poor) general purpose languages over time. 55 * Security issues related to leaving proper escaping to the user. 56 * Well-formedness issues due to representing HTML as string fragments rather than first class values. 57 * Reuse issues due to not treating HTML as first class values (i.e. reuse is achieved by textual inclusion rather than composition).