Skip to content

Commit 45e2d36

Browse files
committed
feat: smaller improvements in view module
- restructure library imports: external then internal - standards compliant output declaration - lookup without try-catch - disallow legacy class-syntax - filter data-template attributes
1 parent 6469c79 commit 45e2d36

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed
Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
xquery version "3.1";
22

3-
import module namespace app="http://exist-db.org/xquery/app" at "app.xql";
4-
import module namespace config="http://exist-db.org/xquery/apps/config" at "config.xqm";
53

64
import module namespace templates="http://exist-db.org/xquery/html-templating";
75
import module namespace lib="http://exist-db.org/xquery/html-templating/lib";
86

9-
declare option exist:serialize "method=html5 media-type=text/html";
7+
(: The following modules provide functions which will be called by the templating :)
8+
import module namespace config="http://exist-db.org/xquery/apps/config" at "config.xqm";
9+
import module namespace app="http://exist-db.org/xquery/app" at "app.xql";
10+
1011

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

0 commit comments

Comments
 (0)