c6f92261925b04abe67a34bbce9b18906a51364d
[squeep-html-template-helper] / README.md
1 # @squeep/html-template-helper
2
3 Simplistic helpers for rendering HTML and boilerplate.
4
5 Specific to Squeep Framework Applications, this module has strong opinions and makes many assumptions.
6
7 ## API
8
9 - `initContext(ctx)`
10 - `htmlPage(pagePathLevel, ctx, options, main = [])`
11 - `dateOrNot(date, otherwise)`
12 - `dateFormat(date, pInf nInf, otherwise)`
13 - `timeElement(date, options)`
14 - `secondsToPeriod(seconds)`
15 - `indented(intent, list)`
16 - `UL(items, indent, attributes, itemAttributesGenerator)`
17 - `OL(items, indent, attributes, itemAttributesGenerator)`
18 - `LI(item, indent, attributes)`
19
20 ### Context
21
22 The context is referenced for authenticated user information, as well as messaging.
23
24 - `ctx.session.authenticatedIdentifier`
25 - `ctx.session.authenticatedProfile`
26
27 If either of these are present, a navigation link is added to the page header allowing the user to log out.
28 The link will point relatively to `/admin/logout`.
29
30 - `ctx.url`
31
32 If present, added as a query parameter (`r`, for redirect) to the logout link.
33
34 - `ctx.errors`
35 - `ctx.notifications`
36
37 Lists of errors and notices to show at top of page, before main content.
38 `initContext` will create the arrays.
39
40 ### Options
41
42 - `options.pageTitle` - title and h1
43 - `options.headElements` - list of items added to <head>
44 - `options.bodyAttributes` - object entries get mapped to k="v", included on body element
45 - `options.logoUrl` - appears beside h1 if set
46 - `options.footerEntries` - array of content at bottom of page
47 - `options.navLink` - array of {href, text, class} included in page header
48 - `options.errorHeading` - h2 for error section
49 - `options.errorContent` - additional information included ahead of list of errors
50 - `options.notificationHeading` - h2 for notice section
51 - `options.notificationContent` - additional information included ahead of list of notices
52 - `options.`