├── .github
└── workflows
│ └── test.yml
├── LICENSE
├── README.md
├── examples
└── dice
│ ├── Dice.gif
│ ├── README.md
│ ├── app.pl
│ ├── dice.svg
│ ├── htmx.min.js
│ ├── index.html
│ └── lyncex.pl
├── expr.pl
├── expr_tests.lgt
├── filters.pl
├── filters_tests.lgt
├── parser.pl
├── parser_tests.lgt
├── render.pl
├── templates
├── a.in.html
├── a.out.html
├── b.in.html
├── b.out.html
├── base.html
├── c.in.html
├── c.out.html
├── child.html
├── child.out.html
├── child3.html
├── d.in.html
├── d.out.html
├── e.in.html
├── f.in.html
├── footer.html
├── g.in.html
├── grandparent.html
├── h.in.html
├── h.out.html
├── i.in.html
├── issue-4.in.html
├── j.in.html
├── j.out.html
└── parent.html
├── teruel.pl
├── tester.lgt
└── tests.lgt
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Test
2 | on: [push]
3 |
4 | jobs:
5 | test:
6 | runs-on: ubuntu-22.04
7 | steps:
8 | - name: Install Rust cargo
9 | uses: actions-rs/toolchain@v1
10 | with:
11 | toolchain: stable
12 | profile: minimal
13 | components: cargo
14 | - name: Checkout
15 | uses: actions/checkout@v3
16 | - name: Checkout Scryer Prolog
17 | uses: actions/checkout@v3
18 | with:
19 | repository: mthom/scryer-prolog
20 | path: scryer-prolog
21 | - name: Compile Scryer Prolog
22 | run: cargo build --release
23 | working-directory: scryer-prolog
24 | - name: Install Scryer Prolog
25 | run: sudo cp scryer-prolog/target/release/scryer-prolog /usr/bin/scryer-prolog
26 | - name: Install Logtalk
27 | uses: logtalk-actions/setup-logtalk@master
28 | with:
29 | logtalk-version: 3.70.0
30 | - name: Execute tests
31 | run: logtalk_tester -p scryer
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Teruel - Template engine for Prolog
2 |
3 | Teruel is a template engine in ISO Prolog, inspired by Tera and Jinja.
4 |
5 | # Installation
6 |
7 | # API Usage
8 |
9 | Load the library:
10 |
11 | ```
12 | :- use_module('teruel.pl').
13 | ```
14 |
15 | The predicate `render/3` will be available for you.
16 |
17 | * `render(+Filename, +Vars, -Output)`.
18 | - Filename. The template path
19 | - Vars. A list of pairs for the variables you want to be available in the template
20 | - Output. The output text after rendering.
21 |
22 | ```
23 | render("templates/i.in.html", ["username"-"aarroyoc", "links"-["https://github.com", "https://adrianistan.eu"]], Output).
24 | ```
25 |
26 | If you're using the Scryer HTTP server and you want to render HTML files, you can simplify your code by using the predicate `html_render_response/2,3`.
27 |
28 | * `html_render_response(Response, +Filename, +Vars)`.
29 | - Response. The Scryer HTTP response
30 | - Filename. The template path
31 | - Vars. A list of pairs for the variables you want to be available in the template
32 |
33 | * `html_render_response(Response, +Filename)`.
34 | - Same as `html_render_response/3` but with Vars = [].
35 |
36 | # Manual
37 |
38 | Teruel is a template engine. It takes a text file annotated with some code in delimiters and returns a processed text file (renders it). It is usually used with HTML, but Teruel doesn't make any assumption.
39 |
40 | There are 3 kinds of delimiters:
41 |
42 | * Comments, which do nothing
43 | * Expressions, which calculate a value
44 | * Statements, which allows to control flow
45 |
46 | ## Comments
47 |
48 | Comments use `{#` and `#}`. Text inside comments doesn't get rendered.
49 |
50 | For example:
51 |
52 | ```
53 | {# TODO: Add users #}
54 |
55 | ```
56 |
57 | renders:
58 |
59 | ```
60 |
61 | ```
62 |
63 | ## Expressions
64 |
65 | Expressions `{{` `}}` are code that evaluate to a value. Also, you can include expressions in some statements like if (see if statement). They can contain variables (which are defined by you, see API Usage) and some operations. However it is not a good idea to create complex expressions in the template, move that logic to your Prolog code.
66 |
67 | The most basic expression is just rendering a variable:
68 |
69 | ```
70 | Hello {{ name }}
71 | ```
72 |
73 | renders to (Vars = ["name"-"Adrián"]):
74 |
75 | ```
76 | Hello Adrián
77 | ```
78 |
79 | Variables can be: numbers, strings, lists and maps. If you want to access a field on a map use the dot syntax:
80 |
81 | ```
82 | Hello {{ user.display_name }}
83 | ```
84 |
85 | renders to (Vars = ["user"-["display_name"-"Adrián"]])
86 |
87 | ```
88 | Hello Adrián
89 | ```
90 |
91 | ### Math in expressions
92 |
93 | If a variable is a number, you can do some math in it.
94 |
95 | * `+` performs sum, `{{ 1 + 1 }}` renders `2`
96 | * `-` performs substraction, `{{ 2 - 1}}` renders `1`
97 | * `/` performs division, `{{ 10 / 2 }}` renders `5`
98 | * `*` performs multiplication, `{{ 2 * 2 }}` renders `4`
99 | * `%` performs modulo, `{{ 10 % 3 }}` renders `1`
100 |
101 | They follow the usual priority rules (multiplication, division and modulo higher) but you can use parenthesis, `{{ (1 + 3) * 3 + 1 }}` renders: `13`
102 |
103 | > __A note about whitespace.__ Teruel is very whitespace sensitive, if your template isn't rendering check that you have just 1 whitespace between things. Things like 1+1 won't be recognised: please use 1 + 1
104 |
105 |
106 | ### Filters
107 |
108 | Values can be piped through a filter. A filter takes an input, some parameters (some filters only) and return an output. That output can be filtered too, making chains of filters. Filters use `|` to separate between them but the first one cannot be a filter, it needs to be a variable.
109 |
110 | For example:
111 | ```
112 | {{ name | lower | truncate(length=4) }}
113 | ```
114 |
115 | renders (Vars = ["name"-"Adrián"])
116 |
117 | ```
118 | adri
119 | ```
120 |
121 | The complete list of filters Teruel has can be found below.
122 |
123 |
124 | ### Comparison and logic in expressions
125 |
126 | Expressions, as we said earlier, can also be used in some statements like if. If you want to use them there, you probably want to know about the comparisons and logic operators. If used directly, they will render `true` or `false`.
127 |
128 | To do comparisons: `==`, `!=`, `>=`, `<=`, `>` and `<` with their usual meanings.
129 |
130 | To combine comparisons, use the logic operators: `and`, `or` and `not` with their usual meanings.
131 |
132 | For example:
133 | ```
134 | {{ 5 >= 4 or 3 < 1 }}
135 | ```
136 |
137 | renders:
138 |
139 | ```
140 | true
141 | ```
142 |
143 | ## Statements
144 |
145 | Statements, `{%` and `%}`, can be used for more advanced stuff, like control flow and inheritance.
146 |
147 | ### If
148 |
149 | The `if` statement allows you to conditionally render a piece of template based on a expression. You can use `{% else %}` to render a piece of template if the expression is false.
150 |
151 | Let's see an example:
152 |
153 | ```
154 | {% if user == "admin" %}
155 |
165 | ```
166 |
167 | ### For
168 |
169 | The `for` statement loops over a list, repeating the piece of template for each element on the list, which is available in a new created variable.
170 |
171 | ```
172 | {% for link in links %}
173 | {{ link }}
174 | {% endfor %}
175 | ```
176 |
177 | renders (Vars = ["links"-["https://github.com", "https://adrianistan.eu"]])
178 |
179 | ```
180 | https://github.com
181 | https://adrianistan.eu
182 | ```
183 |
184 | ### Raw
185 |
186 | Teruel uses some special characters as delimiters, so you can't use them in your text code unless you put them inside a `raw` statement. This statements don't do any kind of processing inside, copying the content as-is.
187 |
188 | ```
189 | {% raw %}
190 | {{ user }}
191 | {% endraw %}
192 | ```
193 |
194 | renders:
195 |
196 | ```
197 | {{ user }}
198 | ```
199 |
200 | ### Filter
201 |
202 | You can also use filter statements to apply a filter to a large chunk of template. They cannot be chained, but they can be nested (you can put a filter statement inside of another one).
203 |
204 | ```
205 | {% filter lower %}
206 | HELLO WORLD
207 | {% endfilter %}
208 | ```
209 |
210 | renders:
211 |
212 | ```
213 | hello world
214 | ```
215 |
216 | ### Include
217 |
218 | Load the contents of another template file and put it there in the main file. You cannot use variables as the filename.
219 |
220 | ```
221 | {% include "footer.html" %}
222 | ```
223 |
224 |
225 | ### Block and extends (inheritance)
226 |
227 | Teruel supports Jinja-like inheritance. What does that mean? It means you can create documents based on a parent template and just filling the "blocks".
228 |
229 | For example, take a "base.html" template:
230 | ```
231 |
232 |
233 |
234 | {% block head %}
235 |
236 | {% block title %}{% endblock %} - My Webpage
237 | {% endblock %}
238 |
239 |
240 |
{% block content %}{% endblock %}
241 |
246 |
247 |
248 | ```
249 |
250 | It defines a template, with some pieces surrounded by block statements. This blocks can be overriden by other templates that extend this one. For example, a "child.html" could be:
251 |
252 | ```
253 | {% extends "base.html" %}
254 | {% block title %}Index{% endblock %}
255 | {% block head %}
256 | {{ super }}
257 | {% raw %}
258 |
261 | {% endraw %}
262 | {% endblock %}
263 | {% block content %}
264 |
Index
265 |
266 | Welcome to my awesome homepage.
267 |
268 | {% endblock %}
269 | ```
270 | Child templates must start with an `extends` statement and can only contain, at the top level, block statements. The block statements use the same identifier to override the default content of the original template. However, the special variable `super`, allows us to render the base.html block too.
271 |
272 | Rendering will give us:
273 |
274 | ```
275 |
276 |
277 |
278 |
279 | Index - My Webpage
280 |
283 |
284 |
285 |
286 |
Index
287 |
288 | Welcome to my awesome homepage.
289 |
290 |
291 |
294 |
295 |
296 | ```
297 |
298 | ## Filter list
299 |
300 | Here are the list of filters Teruel supports:
301 |
302 | * `lower` - Convert uppercase letters to lowercase
303 | * `upper` - Convert lowercase letters to uppercase
304 | * `length` - Counts the number of chars a string has or the number of items in a list
305 | * `wordcount` - Counts the number of words a string has
306 | * `capitalize` - Converts the first letter to uppercase, the rest to lowercase
307 | * `trim` - Removes the whitespaces at the start and at the end
308 | * `trim_start` - Removes the whitespaces at the start
309 | * `trim_end` - Remove the whitespaces at the end
310 | * `truncate(length=N)` - Truncates the string to the first N characters
311 | * `first` - First element of an array
312 | * `last` - Last element of an array
313 | * `nth(n=N)` - Element N of the array. Starts counting at 0
314 | * `replace(from=From, to=To)` - Replaces the From substring with the To substring in a bigger string.
315 | * `title` - Removes spaces and capitalizes the first letter of each word
316 | * `join(sep=Sep)` - Joins a list of strings with sep string in between
317 | * `reverse` - Reverse string or list
318 | * `sort` - Sort a list
319 | * `sort(key=Key)` - Sort a list by looking at the value of the key. Works for list of pairs.
320 | * `unique` - Removes duplicated elements
321 | * `floor` - Converts the number to the largest integer smaller or equal
322 | * `ceiling` - Converts the number to the smallest integer larger or equal
323 |
--------------------------------------------------------------------------------
/examples/dice/Dice.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aarroyoc/teruel/3c1e0d206a45dc98bde8519360c7ab1bc9381ef3/examples/dice/Dice.gif
--------------------------------------------------------------------------------
/examples/dice/README.md:
--------------------------------------------------------------------------------
1 | # Dice Sample
2 |
3 | This example demonstrates how to integrate the Scryer HTTP server with Teruel and htmx.
4 |
5 | 
6 |
7 | Running it:
8 |
9 | ```
10 | scryer-prolog app.pl
11 |
12 | ?- listen(8080).
13 | ```
14 |
15 | Visit http://localhost:8080
--------------------------------------------------------------------------------
/examples/dice/app.pl:
--------------------------------------------------------------------------------
1 | :- use_module(library(random)).
2 | :- use_module(lyncex).
3 | :- use_module(library(time)).
4 | :- use_module('../../teruel.pl').
5 |
6 | listen(Port) :-
7 | http_listen(Port, [
8 | get(/, index),
9 | get('dice.svg', dice),
10 | get('htmx.min.js', htmx)
11 | ]).
12 |
13 | index(_Request, Response) :-
14 | html_render_response(Response, "index.html").
15 |
16 | dice(_Request, Response) :-
17 | random_integer(1, 7, N),
18 | time(render("dice.svg", ["n"-N], DiceSvg)),!,
19 | http_status_code(Response, 200),
20 | http_headers(Response, ["content-type"-"image/svg+xml"]),
21 | http_body(Response, text_custom(DiceSvg)).
22 |
23 | htmx(_Request, Response) :-
24 | http_status_code(Response, 200),
25 | http_headers(Response, ["content-type"-"text/javascript"]),
26 | http_body(Response, file("htmx.min.js")).
--------------------------------------------------------------------------------
/examples/dice/dice.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/examples/dice/htmx.min.js:
--------------------------------------------------------------------------------
1 | (function(e,t){if(typeof define==="function"&&define.amd){define([],t)}else{e.htmx=t()}})(typeof self!=="undefined"?self:this,function(){return function(){"use strict";var D={onLoad:t,process:rt,on:N,off:I,trigger:lt,ajax:$t,find:w,findAll:S,closest:O,values:function(e,t){var r=Ot(e,t||"post");return r.values},remove:E,addClass:C,removeClass:R,toggleClass:q,takeClass:L,defineExtension:Qt,removeExtension:er,logAll:b,logger:null,config:{historyEnabled:true,historyCacheSize:10,refreshOnHistoryMiss:false,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:true,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:true,attributesToSettle:["class","style","width","height"],withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",disableSelector:"[hx-disable], [data-hx-disable]",useTemplateFragments:false,scrollBehavior:"smooth"},parseInterval:h,_:e,createEventSource:function(e){return new EventSource(e,{withCredentials:true})},createWebSocket:function(e){return new WebSocket(e,[])},version:"1.6.0"};var r=["get","post","put","delete","patch"];var n=r.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function h(e){if(e==undefined){return undefined}if(e.slice(-2)=="ms"){return parseFloat(e.slice(0,-2))||undefined}if(e.slice(-1)=="s"){return parseFloat(e.slice(0,-1))*1e3||undefined}return parseFloat(e)||undefined}function c(e,t){return e.getAttribute&&e.getAttribute(t)}function s(e,t){return e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function F(e,t){return c(e,t)||c(e,"data-"+t)}function l(e){return e.parentElement}function P(){return document}function d(e,t){if(t(e)){return e}else if(l(e)){return d(l(e),t)}else{return null}}function X(e,t){var r=null;d(e,function(e){return r=F(e,t)});if(r!=="unset"){return r}}function v(e,t){var r=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;return r&&r.call(e,t)}function i(e){var t=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i;var r=t.exec(e);if(r){return r[1].toLowerCase()}else{return""}}function o(e,t){var r=new DOMParser;var n=r.parseFromString(e,"text/html");var i=n.body;while(t>0){t--;i=i.firstChild}if(i==null){i=P().createDocumentFragment()}return i}function u(e){if(D.config.useTemplateFragments){var t=o(""+e+"",0);return t.querySelector("template").content}else{var r=i(e);switch(r){case"thead":case"tbody":case"tfoot":case"colgroup":case"caption":return o("