[mod] update
This commit is contained in:
parent
ddd772f563
commit
cd369cd51e
11 changed files with 429 additions and 220 deletions
|
|
@ -13,6 +13,8 @@ import module namespace p = 'Thyme' at "Thyme.xqm";
|
|||
declare namespace th="http://www.thymeleaf.org";
|
||||
declare namespace layout="http://www.ultraq.net.nz/thymeleaf/layout";
|
||||
|
||||
declare variable $ore:debug:=false(); (: trace messages:)
|
||||
|
||||
declare variable $ore:default-options:=map{"base": file:base-dir(),
|
||||
"layout": true(),
|
||||
"indent": "no"
|
||||
|
|
@ -23,7 +25,8 @@ declare function ore:render($view as xs:string,$opts as map(*),$model as map(*))
|
|||
as document-node(){
|
||||
let $opts:=map:merge(($opts,$ore:default-options))
|
||||
let $doc:=(ore:doc($view,$opts)
|
||||
,message($model,"£ RENDER MODEL(" || $view ||"): "))
|
||||
,message($model,"£ RENDER MODEL(" || $view ||"): ")
|
||||
)
|
||||
let $a:= ore:update($doc,$opts,$model)
|
||||
return ore:decorate($a,$opts)
|
||||
};
|
||||
|
|
@ -38,9 +41,9 @@ declare function ore:update($doc ,$opts as map(*),$model as map(*))
|
|||
replace node $each with (
|
||||
for $item in map:get($model,substring-after($p,","))
|
||||
let $model2:=map:put($model,substring-before($p,","),$item)
|
||||
(:=>trace("MODEL2:"):)
|
||||
(:=>ore:trace("MODEL2:"):)
|
||||
let $x:=ore:update($each,$opts,$model2)
|
||||
return $x (:=>trace("DD: "):)
|
||||
return $x (:=>ore:trace("DD: "):)
|
||||
))
|
||||
,delete node @th:each
|
||||
)
|
||||
|
|
@ -62,10 +65,10 @@ declare %updating function ore:update-attrib($context as node(),$name as xs:stri
|
|||
as empty-sequence(){
|
||||
for $at in $context//*/@th:*[local-name(.) eq $name]
|
||||
where not($at/ancestor::*/@th:each)
|
||||
let $target:=$at/../@*[name() eq $name]=>trace("£ target: ")
|
||||
let $target:=$at/../@*[name() eq $name]=>ore:trace("£ target: ")
|
||||
return (
|
||||
replace value of node $target with
|
||||
ore:expression($at, $model)=>trace("£ ore:expression: ")
|
||||
ore:expression($at, $model)=>ore:trace("£ ore:expression: ")
|
||||
,delete node $at
|
||||
)
|
||||
};
|
||||
|
|
@ -73,7 +76,7 @@ for $at in $context//*/@th:*[local-name(.) eq $name]
|
|||
(: load doc from base folder:)
|
||||
declare function ore:doc($file as xs:string,$opts as map(*))
|
||||
as document-node(){
|
||||
let $f:=file:resolve-path($file,$opts?base)=>trace("ore:doc")
|
||||
let $f:=file:resolve-path($file,$opts?base)=>ore:trace("ore:doc")
|
||||
return doc($f)
|
||||
};
|
||||
|
||||
|
|
@ -113,7 +116,7 @@ as xs:string{
|
|||
(:~ Return value of $atrib from model :)
|
||||
declare function ore:expression($atrb as xs:string,$model as map(*))
|
||||
as xs:string{
|
||||
let $p:=ore:parse-text($atrb)=>trace("ore:expression: ")
|
||||
let $p:=ore:parse-text($atrb)=>ore:trace("ore:expression: ")
|
||||
let $exp:=substring-after($p,",")
|
||||
return switch(substring-before($p,","))
|
||||
|
||||
|
|
@ -136,7 +139,7 @@ as xs:string{
|
|||
declare function ore:expression-link($exp as xs:string)
|
||||
as xs:string {
|
||||
switch (true())
|
||||
case starts-with($exp=>trace("EEEE: "), "http")
|
||||
case starts-with($exp=>ore:trace("EEEE: "), "http")
|
||||
case starts-with($exp, "//")
|
||||
return $exp
|
||||
case starts-with($exp, "/")
|
||||
|
|
@ -233,3 +236,12 @@ as xs:string{
|
|||
}
|
||||
return string($s)
|
||||
};
|
||||
|
||||
(:~ trace:)
|
||||
declare function ore:trace($value as item()*, $label as xs:string)
|
||||
as item()*
|
||||
{
|
||||
if($ore:debug)
|
||||
then trace($value,$label)
|
||||
else $value
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue