2017-05-22 14:27:25 +01:00
|
|
|
(:~
|
|
|
|
: create app.js from vue files
|
|
|
|
:)
|
|
|
|
import module namespace html5="text.html5" at "html5parse.xqm";
|
|
|
|
import module namespace fw="quodatum:file.walker";
|
|
|
|
declare namespace c="http://www.w3.org/ns/xproc-step";
|
|
|
|
declare namespace Document="java:ch.digitalfondue.jfiveparse.Document";
|
|
|
|
declare namespace Element="java:ch.digitalfondue.jfiveparse.Element";
|
|
|
|
declare namespace Node="java:ch.digitalfondue.jfiveparse.Node";
|
2017-06-01 12:42:13 +01:00
|
|
|
|
2017-05-22 14:27:25 +01:00
|
|
|
declare namespace functx = "http://www.functx.com";
|
|
|
|
declare variable $SRC:="C:/Users/andy/git/vue-poc/src/vue-poc/templates/";
|
|
|
|
declare variable $CORE:="C:/Users/andy/git/vue-poc/src/vue-poc/static/core.js";
|
|
|
|
declare variable $DEST:="C:/Users/andy/git/vue-poc/src/vue-poc/static/app-gen.js";
|
|
|
|
|
|
|
|
(:~
|
2017-06-01 12:42:13 +01:00
|
|
|
: generate javascript vue call from vue files in source folder and core.js
|
2017-05-22 14:27:25 +01:00
|
|
|
:)
|
|
|
|
declare function local:process($doc)
|
|
|
|
{
|
2017-06-01 12:42:13 +01:00
|
|
|
let $tempNode:= html5:getElementFirstByTagName($doc,"template")
|
2017-05-22 14:27:25 +01:00
|
|
|
let $template:= Node:getInnerHTML($tempNode)
|
2017-05-22 17:02:22 +01:00
|
|
|
let $id := Element:getAttribute($tempNode,"id")
|
2017-05-22 14:27:25 +01:00
|
|
|
let $name:=functx:capitalize-first($id)=>trace("ID")
|
|
|
|
|
2017-06-01 12:42:13 +01:00
|
|
|
let $script:= html5:getElementFirstByTagName($doc,"script")
|
2017-06-06 13:32:41 +01:00
|
|
|
let $script:= Node:getInnerHTML($script)=>substring-after("{")
|
|
|
|
let $js:= ``[const `{$name}`=Vue.extend({template:` `{$template}` `,
|
|
|
|
`{$script}`
|
2017-05-22 14:27:25 +01:00
|
|
|
);
|
|
|
|
]``
|
2017-05-22 17:02:22 +01:00
|
|
|
return if(empty($id)) then () else $js
|
2017-05-22 14:27:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
declare function functx:capitalize-first
|
|
|
|
( $arg as xs:string? ) as xs:string?
|
|
|
|
{
|
|
|
|
concat(upper-case(substring($arg,1,1)), substring($arg,2))
|
|
|
|
};
|
2017-06-01 12:42:13 +01:00
|
|
|
|
2017-05-22 14:27:25 +01:00
|
|
|
let $files:= fw:directory-list($SRC,map{"include-filter":".*\.vue"})
|
2017-06-01 12:42:13 +01:00
|
|
|
//c:file/@name/resolve-uri(.,base-uri(.))
|
2017-05-22 14:27:25 +01:00
|
|
|
let $docs:=$files!(fetch:text(.)=>html5:doc()=>local:process())
|
2017-06-01 12:42:13 +01:00
|
|
|
let $comment:="// generated " || current-dateTime() || "

"
|
|
|
|
return file:write-text($DEST,string-join(($comment,$docs,fetch:text($CORE))))
|