Skip to content

Commit 538f479

Browse files
committed
[enhancement] improve view module
- refactor for readability - make use of newer templating features - filter templating attributes from rendered HTML - disallow legacy class-syntax - remove unnecessary try-catch from lookup function which is now named, too
1 parent 62035a5 commit 538f479

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed
Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
xquery version "3.0";
1+
xquery version "3.1";
2+
23

34
import module namespace templates="http://exist-db.org/xquery/html-templating";
45
import module namespace lib="http://exist-db.org/xquery/html-templating/lib";
@@ -11,19 +12,26 @@ import module namespace review="http://exist-db.org/xquery/documentation/review"
1112
import module namespace diag="http://exist-db.org/xquery/diagnostics" at "diagnostics.xql";
1213
import module namespace app="http://exist-db.org/apps/docs/app" at "app.xql";
1314

14-
declare option exist:serialize "method=html5 media-type=text/html";
1515

16-
let $config := map {
16+
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
17+
18+
declare option output:method "html5";
19+
declare option output:media-type "text/html";
20+
21+
declare function local:lookup ($functionName as xs:string, $arity as xs:integer) {
22+
function-lookup(xs:QName($functionName), $arity)
23+
};
24+
25+
declare variable $local:templating-configuration := map {
26+
$templates:CONFIG_FILTER_ATTRIBUTES : true(),
27+
$templates:CONFIG_USE_CLASS_SYNTAX : false(),
1728
$templates:CONFIG_APP_ROOT : $config:app-root,
1829
$templates:CONFIG_STOP_ON_ERROR : true()
19-
}
20-
let $lookup := function($functionName as xs:string, $arity as xs:integer) {
21-
try {
22-
function-lookup(xs:QName($functionName), $arity)
23-
} catch * {
24-
()
25-
}
26-
}
27-
let $content := request:get-data()
28-
return
29-
templates:apply($content, $lookup, (), $config)
30+
};
31+
32+
templates:apply(
33+
request:get-data(),
34+
local:lookup#2,
35+
(),
36+
$local:templating-configuration
37+
)

0 commit comments

Comments
 (0)