# HG changeset patch # User Edouard Tisserant # Date 1587286114 -7200 # Node ID 034b6ce4f8853c161ae287a3713450455ee432b2 # Parent 4296ab974d4daaa3a6f790711308e3a63aa40ec9 SVGHMI: Introduced "emit" to simplify producing per-topic code and content from anywhere in code. Applied to debug output, next to JS. diff -r 4296ab974d4d -r 034b6ce4f885 svghmi/detachable_pages.ysl2 --- a/svghmi/detachable_pages.ysl2 Sat Apr 18 14:06:41 2020 +0200 +++ b/svghmi/detachable_pages.ysl2 Sun Apr 19 10:48:34 2020 +0200 @@ -157,9 +157,7 @@ template "*", mode="per_page_widget_template"; -debug:detachable_pages; - -template "debug:detachable-pages", mode="debug" { +emit "debug:detachable-pages" { | DETACHABLES: foreach "$detachable_elements"{ diff -r 4296ab974d4d -r 034b6ce4f885 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Sat Apr 18 14:06:41 2020 +0200 +++ b/svghmi/gen_index_xhtml.xslt Sun Apr 19 10:48:34 2020 +0200 @@ -1,5 +1,5 @@ - + @@ -157,7 +157,6 @@ - @@ -178,7 +177,8 @@ - + + Raw HMI tree @@ -196,7 +196,7 @@ - + ID, x, y, w, h @@ -461,7 +461,7 @@ - + DETACHABLES: @@ -591,7 +591,7 @@ - + Unlinked : @@ -600,6 +600,14 @@ + + + var hmi_widgets = { + + + } + + @@ -2079,16 +2087,11 @@ - + var hmi_hash = [ ]; - var hmi_widgets = { - - - } - var heartbeat_index = @@ -3222,20 +3225,20 @@ }; - - - - - : - - - + Made with SVGHMI. https://beremiz.org - + + + + : + + + + diff -r 4296ab974d4d -r 034b6ce4f885 svghmi/gen_index_xhtml.ysl2 --- a/svghmi/gen_index_xhtml.ysl2 Sat Apr 18 14:06:41 2020 +0200 +++ b/svghmi/gen_index_xhtml.ysl2 Sun Apr 19 10:48:34 2020 +0200 @@ -3,6 +3,14 @@ // overrides yslt's output function to set CDATA decl output(method, cdata-section-elements="xhtml:script"); +// helper to emit some content to internal namespaces +decl emit(*name) alias - { + *name; + template *name { + content; + } +}; + istylesheet /* From Inkscape */ xmlns:dc="http://purl.org/dc/elements/1.1/" @@ -13,13 +21,17 @@ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:xhtml="http://www.w3.org/1999/xhtml" + + /* Internal namespaces to allow emit code/content from anywhere */ xmlns:debug="debug" + xmlns:preamble="preamble" + xmlns:epilogue="epilogue" - /* Our namespace to invoke python code */ + /* Namespace to invoke python code */ xmlns:ns="beremiz" + extension-element-prefixes="ns func exsl regexp str dyn" - exclude-result-prefixes="ns str regexp exsl func dyn debug" { - + exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue" { const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]"; @@ -37,18 +49,16 @@ include scripts.ysl2 - template "*[namespace-uri()='debug']", mode="debug_as_comment" { - comment { - | «local-name()» : - apply ".", mode="debug"; - } - } - template "/" { comment > Made with SVGHMI. https://beremiz.org // all debug output from included definitions, as comments - // apply "document('')/*/debug:*", mode="debug_as_comment"; + foreach "document('')/*/debug:*" { + comment { + | «local-name()» : + apply "."; + } + } html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" diff -r 4296ab974d4d -r 034b6ce4f885 svghmi/geometry.ysl2 --- a/svghmi/geometry.ysl2 Sat Apr 18 14:06:41 2020 +0200 +++ b/svghmi/geometry.ysl2 Sun Apr 19 10:48:34 2020 +0200 @@ -7,10 +7,8 @@ // const "geometry", "ns:GetSVGGeometry()"; -debug:geometry; - // Debug data -template "debug:geometry", mode="debug" { +emit "debug:geometry" { | ID, x, y, w, h foreach "$geometry" | «@Id» «@x» «@y» «@w» «@h» diff -r 4296ab974d4d -r 034b6ce4f885 svghmi/hmi_tree.ysl2 --- a/svghmi/hmi_tree.ysl2 Sat Apr 18 14:06:41 2020 +0200 +++ b/svghmi/hmi_tree.ysl2 Sun Apr 19 10:48:34 2020 +0200 @@ -126,8 +126,6 @@ result "$class_a and $class_b and $class_a = $class_b"; } -debug:hmi_tree; - // Debug data template "*", mode="testtree"{ param "indent", "''"; @@ -138,7 +136,7 @@ with "indent" value "concat($indent,'>')" }; } -template "debug:hmi-tree", mode="debug" { +emit "debug:hmi-tree" { | Raw HMI tree apply "$hmitree", mode="testtree"; | diff -r 4296ab974d4d -r 034b6ce4f885 svghmi/inline_svg.ysl2 --- a/svghmi/inline_svg.ysl2 Sat Apr 18 14:06:41 2020 +0200 +++ b/svghmi/inline_svg.ysl2 Sun Apr 19 10:48:34 2020 +0200 @@ -115,8 +115,7 @@ const "result_svg" apply "/", mode="inline_svg"; const "result_svg_ns", "exsl:node-set($result_svg)"; -debug:inline_svg; -template "debug:inline-svg", mode="debug" { +emit "debug:inline-svg" { | Unlinked : foreach "$to_unlink"{ | «@id»