Home - noradle/plsql-print GitHub Wiki

Welcome to the plsql-print wiki!

use noradle's printing API for html/xml is simple, directly, flexible.

see direct-print-vs-templating

Design considerations:

  1. code must be concise, code less do more
  • API should be shortest itself, they all like x.x(), just 2 characters.
  • code must be short for attributes
  • inspired by jade for "#id.class"
  • html5 data-attribute must have shortcut
  • runtime conversion must be simple and performant, just string replacement is ok
  1. the html/xml structure in PL/SQL code is clear
  • html keep indent while PL/SQL code is autoformate in IDE
  • keep tag <> symbol
  1. 不为每个标签都提供一个API输出接口
  • 和原先API的完全不同,原来的为每个标签设计一个API
  • 扩展标签就可以直接在字符串中体现
  • 一个非常精简、易学的通用标签输出API。
  1. 其他
  • 更像传统静态页面和jade的结合体。所有必须书写 <> ,支持 #id .class,支持 < 前的缩进,属性值不用双引号"括起来
  • 动态绑定支持,包括 tag/id/class/attrName/attrValue/partial,包括 cut 参数,可以绑定不超过9个参数,支持没有参数的绑定
  • 简单、一致、固定、高效的输出 API,除了 cut 参数外,基本上都无需在调用时指定参数名称,不处理url逻辑

skeleton

line/tag/html/xml glance

  • h.* : API to set response headers and meta data or indicators (have its own doc)
  • b.* : basic API to print response body
  • l : url link that can re-target
  • p.* : old complex tag print API (deprecated, no documentation)
  • x.* (tag.*) : previous version concise tag output, (deprecated)
  • o.* (ztag.*) : most concise tag print API
  • m.* (multi.*) : concise template repeater
  • tr.* (tree.*)` : concise template repeater for tree-like hierachical tag structure
  • tb.* (list.*)` : API that assist table meta data printing
  • attr.* : pre set following tag's attributes (experimental)
  • tagp.* : use attr.* to fill in its tag's attributes (experimental)

They are all based on the above b.xxx basic output API except for h.*

You can reference their respective documents.

  • b.l(text) | b.line(text) | b.writeln(text) : write text and add line-break to response body
  • b.w(text) | b.string(text) | b.write(text) : write text to response body

note: b.l,b.line,b.writeln are aliases for each other, b.w,b.string,b.write are aliases for each other.

TAG API

source [tag.spc][]/[tag.bdy][]

  • jade like #id.class1.class2
  • name-only attribute and shortcut
  • data-* attribute support
  • shortcut API for a.href|img.src|script.src|link.href for url attribute
  • shortcut API for input.value
  • text placeholder replacement with single|array value(s)
  • support content escape, stripe < and >

source [ztag.spc][]/[ztag.bdy][]

  • 和 TAG 版本相似
  • API 更为少、更精简
  • 兼容不简写的原始 html tag
  • 兼容 plain text
  • 值替换更简洁方便

source [multi.spc][]/[multi.bdy][]

  • repeat applying template string for every elements of a array
  • repeat applying template string for every row of a sys_refcursor

source [tree.spc][]/[tree.bdy][]

  • print hierachical SQL query result to nested UL/LI like structure

source [list.spc][]/[list.bdy][]

  • configure table caption, thead column headers
  • print sys_refcursor to tbody

doc url.fnc

source [url.fnc][]

  • print url to a procedure in the same package
  • print url to a procedure in other package
  • print url relative to app's static root url
  • print url relative to a predefined named url prefix

css print

  • set a <link>|<style> embed point in middle of html, usually <head>
  • support auto scaling length value
  • print css rule under the current #id

summary

performance

  • TAG API is quick for that it's operated in CPU local cache, little change cause bottleneck
  • multi API use precompiled once template to apply to each item in array
  • so string parse/manipulation operation will not be so big
⚠️ **GitHub.com Fallback** ⚠️