;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\207" [require s ht dash cl-lib] 2) #@53 Render a mustache TEMPLATE with hash table CONTEXT. (defalias 'mustache-render #[(template context) "\302\303\304\305!!! \"\207" [template context mst--render-section-list mst--parse mst--clean-whitespace mst--lex] 5 (#$ . 183)]) #@89 A list of paths to be searched for mustache partial templates (files ending .mustache). (defvar mustache-partial-paths nil (#$ . 420)) #@263 What type of key we expect in contexts. Can take the value 'string or 'keyword. For 'string we expect contexts of the form: #s(hash-table data ("name" "J. Random user")) for 'keyword we expect contexts of the form: #s(hash-table data (:name "J. Random user")) (defvar mustache-key-type 'string (#$ . 562)) #@132 Iterate through TEMPLATE, splitting {{ tags }} and bare strings. We return a list of lists: ((:text "foo") (:tag "variable-name")) (defalias 'mst--lex #[(template) "\306\307\310\311 \312\"\204\232\313\n \"\313 \"\f\203\216 \203\216\f W\203\216 G\314ZW\203; \314\\\234\315=\203; T \f\nG\\ O G\\\f\316V\203Y\317 \316\fODB\320\321\"\203{\322\323O\324\325\"\211@A@*\202\204\326\327!DB \310O*\202\226\317 DB\312*\202\237+\207" [lexemes close-delimeter open-delimeter template open-index close-index "{{" "}}" nil s-equals\? "" s-index-of 2 125 0 :text s-matches-p "^=.+ .+=$" 1 -1 s-split " " :tag s-trim continue-from-index between-delimeters delimeter-spec spec-parts] 5 (#$ . 877)]) #@137 Given a list of LEXEMES, remove whitespace around sections and comments if they're on their own on a line. Modifies the original list. (defalias 'mst--clean-whitespace #[(lexemes) "G\306Z\307 \nW\203\205 \234 T\234 \306\\\234\310 !\203}\311\f!\204.\312\f!\203}\310 !\203}\313\314 !\315\316\317#)\266\203\203}\320\314 !\315\316\317#)\266\203\203} <\203s\233\321 !\240\210\202|\321 !I\210*+ T\211\202*\207" [lexemes i --dotimes-limit-- third second first 2 0 mst--text-p mst--section-tag-p mst--comment-tag-p "\n *$" mst--tag-text nil t string-match "^\n" mst--no-trailing-newline inhibit-changing-match-data #1=#:v #2=#:v] 8 (#$ . 1618)]) (defalias 'mst--tag-text '-second-item "Returns the text context of a tag.") #@58 Replace " " or " " at the end of a plain text LEXEME. (defalias 'mst--no-trailing-newline #[(lexeme) "\301\302\303\304\305!#D\207" [lexeme :text replace-regexp-in-string "\n *$" "" mst--tag-text] 6 (#$ . 2387)]) #@18 Is LEXEME a tag? (defalias 'mst--tag-p #[(lexeme) "@\301=\207" [lexeme :tag] 2 (#$ . 2609)]) #@26 Is LEXEME a section tag? (defalias 'mst--section-tag-p #[(lexeme) "\301!\206\302!\206\303!\207" [lexeme mst--open-section-tag-p mst--inverted-section-tag-p mst--close-section-tag-p] 2 (#$ . 2709)]) #@72 Is LEXEME an open section tag? See also `mst--inverted-section-tag-p'. (defalias 'mst--open-section-tag-p #[(lexeme) "\301!\205\f\302\303A@\"\207" [lexeme mst--tag-p s-starts-with-p "#"] 3 (#$ . 2920)]) #@36 Is LEXEME an inverted section tag? (defalias 'mst--inverted-section-tag-p #[(lexeme) "\301!\205\f\302\303A@\"\207" [lexeme mst--tag-p s-starts-with-p "^"] 3 (#$ . 3132)]) #@32 Is LEXEME a close section tag? (defalias 'mst--close-section-tag-p #[(lexeme) "\301!\205\f\302\303A@\"\207" [lexeme mst--tag-p s-starts-with-p "/"] 3 (#$ . 3312)]) #@26 Is LEXEME a comment tag? (defalias 'mst--comment-tag-p #[(lexeme) "\301!\205\f\302\303A@\"\207" [lexeme mst--tag-p s-starts-with-p "!"] 3 (#$ . 3485)]) #@38 Is LEXEME an unescaped variable tag? (defalias 'mst--unescaped-tag-p #[(lexeme) "\302!\205A@\303\304 \"\206\303\305 \"\205\306\307 \")\207" [lexeme text mst--tag-p s-starts-with-p "&" "{" s-ends-with-p "}"] 3 (#$ . 3646)]) #@26 Is LEXEME a partial tag? (defalias 'mst--partial-tag-p #[(lexeme) "\301!\205\f\302\303A@\"\207" [lexeme mst--tag-p s-starts-with-p ">"] 3 (#$ . 3884)]) #@29 Is LEXEME a nested section? (defalias 'mst--section-p #[(lexeme) "@:??\207" [lexeme] 1 (#$ . 4045)]) #@23 Is LEXEME plain text? (defalias 'mst--text-p #[(lexeme) "@\301=\207" [lexeme :text] 2 (#$ . 4153)]) #@90 Given a lexed (and optionally parsed) list of LEXEMES, return the original input string. (defalias 'mst--unlex #[(lexemes) "\203;@A\305\n!\203\306\n!\306 !P\2029\307\n!\203/\nA@\310 \311\306 !R)\2029\nA@\211\306 !P)*\207\312\207" [lexemes rest lexeme tag-name text mst--section-p mst--unlex mst--tag-p "{{" "}}" ""] 6 (#$ . 4260)]) #@86 Since `mst--parse-inner' recursively calls itself, we need a shared value to mutate. (defvar mst--remaining-lexemes nil (#$ . 4611)) #@84 Given a list LEXEMES, return a list of lexemes nested according to #tags or ^tags. (defalias 'mst--parse #[(lexemes) "\302 \207" [lexemes mst--remaining-lexemes mst--parse-inner] 1 (#$ . 4750)]) #@98 Parse `mst--remaining-lexemes', and return a list of lexemes nested according to #tags or ^tags. (defalias 'mst--parse-inner #[(&optional section-name) "\304\211\3052L\n\205K\n\211A\242\306!\203%\307\310!!B B\202\311!\203D \310!\232\2048\312\313 \"\210 B\314\305\304\"\210\202 B\2020\210 \203\\\311!\204\\\312\315 \"\210 \237*\207" [lexeme parsed-lexemes mst--remaining-lexemes section-name nil done mst--open-section-p mst--parse-inner mst--section-name mst--close-section-p error "Mismatched brackets: You closed a section with %s, but it wasn't open" throw "Unclosed section: You haven't closed %s"] 4 (#$ . 4953)]) #@28 Is LEXEME a #tag or ^tag ? (defalias 'mst--open-section-p #[(lexeme) "\211\211A\242 @\n\304=\205\305\306 \"\206\305\307 \"+\207" [lexeme #1=#:--dash-source-0-- type value :tag s-starts-with-p "#" "^"] 4 (#$ . 5606)]) #@20 Is LEXEME a /tag ? (defalias 'mst--close-section-p #[(lexeme) "\211\211A\242 @\n\304=\205\305\306 \"+\207" [lexeme #1=#:--dash-source-1-- type value :tag s-starts-with-p "/"] 4 (#$ . 5838)]) #@130 Get the first partial whose file name is NAME.mustache, or nil otherwise. Partials are searched for in `mustache-partial-paths'. (defalias 'mst--get-partial #[(name) "\3062\262<\204 \307\310!\210\311\312 \"\313\211\205\260\f@\314 \313\315#\211\203\247\313 \316\313\211\211\203~\211A\242\211\211\203~\317\n!\313\320\321#)\266\203\203n\313\203~T\2029-)\211 \203\246\322\306\323\324\320\"!r!q\210\325\216\326\327 \"!\210\330ed\"+\"\210))\fA\211\204\313+0\207" [mustache-partial-paths name partial-name path --dolist-tail-- partials --cl-block-nil-- error "`mustache-partial-paths' must be a list of paths" format "%s.mustache" nil directory-files "\\.mustache$" 0 regexp-quote t string-match throw generate-new-buffer " *temp*" #[nil "\301!\205 \302!\207" [#1=#:temp-buffer buffer-name kill-buffer] 2] insert-file-contents-literally expand-file-name buffer-substring-no-properties #2=#:needle it-index it #3=#:elt #4=#:i #5=#:list inhibit-changing-match-data matching-partial #1#] 8 (#$ . 6043)]) #@43 Render a parsed list SECTIONS in CONTEXT. (defalias 'mst--render-section-list #[(sections context) "\301\302\303\304\"\"\207" [sections s-join "" mapcar #[(it) "\302 \"\207" [it context mst--render-section] 3]] 5 (#$ . 7122)]) #@68 Lookup VARIABLE-NAME in CONTEXT, returning DEFAULT if not present. (defalias 'mst--context-get #[(context variable-name &optional default) "\304=\203\f\305\306 P!\307 \n #\207" [mustache-key-type variable-name context default keyword intern ":" gethash] 4 (#$ . 7357)]) #@60 Given a tag {{foo}}, {{& foo}} or {{{foo}}}, return "foo". (defalias 'mst--tag-name #[(tag-text) "\301\302\303\"\203\304\305O\202!\302\306\"\205!\307\310\"\205!\304\311O!\207" [tag-text s-trim s-starts-with-p "&" 1 nil "{" s-ends-with-p "}" -1] 4 (#$ . 7636)]) #@52 Given PARSED-TAG, render it in hash table CONTEXT. (defalias 'mst--render-tag #[(parsed-tag context) "\305!\306!\203\307\202\\\310!\203*\311\n\312 !\307#\211\247\203%\313 ! )\202\\\314!\203I\315\316 \317\320O!!\211\203D\321\f\n\"\202E\307)\202\\\311\n \307#\211\247\203X\313 !\322 !))\207" [parsed-tag inner-text context variable-value partial mst--tag-text mst--comment-tag-p "" mst--unescaped-tag-p mst--context-get mst--tag-name number-to-string mst--partial-tag-p mst--get-partial s-trim 1 nil mustache-render mst--escape-html] 6 (#$ . 7913)]) #@83 Return a copy of TABLE where all the key-value pairs in FROM-TABLE have been set. (defalias 'mst--context-add #[(table from-table) "\303!\304 \n\"\210 )\207" [table new-table from-table copy-hash-table ht-update] 3 (#$ . 8488)]) #@90 Return t if OBJECT is a list. Unlike `listp', does not return t if OBJECT is a function. (defalias 'mst--listp #[(object) "\301!?\205 <\207" [object functionp] 2 (#$ . 8725)]) #@64 Get the name of this SECTION-TAG. E.g. from {{#foo}} to "foo". (defalias 'mst--section-name #[(section-tag) "\301\302!\303\304O!\207" [section-tag s-trim mst--tag-text 1 nil] 4 (#$ . 8910)]) #@89 Given PARSED-LEXEME -- a lexed tag, plain text, or a nested list, render it in CONTEXT. (defalias 'mst--render-section #[(parsed-lexeme context) "\306!\203v@\307 !\310 \n\"\311\312\313#\314 !\203b\315\f!\204*\316\f!\2034\317\320\321\322\f\"\"\202t\323\f!\203D\324 \325 \f\"\"\202t\326\f!\203S\f\327 ! \"\202t\f\203^\324 \"\202t\320\202t\330 !\205t\f\203p\320\202t\324 \",\207\331!\203\201\332 \"\207A@\207" [parsed-lexeme section-tag section-name context context-value section-contents mst--section-p mst--section-name mst--context-get -slice 1 -1 mst--open-section-tag-p mst--listp vectorp s-join "" mapcar #[(it) "\303\304 \n\"\"\207" [section-contents context it mst--render-section-list mst--context-add] 5] hash-table-p mst--render-section-list mst--context-add functionp mst--unlex mst--inverted-section-tag-p mst--tag-p mst--render-tag] 5 (#$ . 9108)]) #@24 Escape HTML in STRING. (defalias 'mst--escape-html #[(string) "\301\302\303\301\304\305\301\306\307\301\310\311\301\312\313#####\207" [string s-replace "\"" """ "'" "'" ">" ">" "<" "<" "&" "&"] 16 (#$ . 10003)]) (provide 'mustache)