{"id":23070166,"url":"https://github.com/strojure/jmustache","last_synced_at":"2025-08-15T13:32:47.568Z","repository":{"id":41118082,"uuid":"508231979","full_name":"strojure/jmustache","owner":"strojure","description":"Clojure adapter to jmustache library.","archived":false,"fork":false,"pushed_at":"2023-03-09T10:05:10.000Z","size":12,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"default","last_synced_at":"2024-11-28T12:09:14.744Z","etag":null,"topics":["adapter","clojure","mustache","template-engine"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/strojure.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-28T09:17:43.000Z","updated_at":"2024-02-02T14:00:50.000Z","dependencies_parsed_at":"2022-08-27T04:11:49.406Z","dependency_job_id":null,"html_url":"https://github.com/strojure/jmustache","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strojure%2Fjmustache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strojure%2Fjmustache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strojure%2Fjmustache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strojure%2Fjmustache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/strojure","download_url":"https://codeload.github.com/strojure/jmustache/tar.gz/refs/heads/default","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229916369,"owners_count":18144129,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adapter","clojure","mustache","template-engine"],"created_at":"2024-12-16T06:19:55.226Z","updated_at":"2024-12-16T06:19:55.651Z","avatar_url":"https://github.com/strojure.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jmustache\n\nClojure adapter to [jmustache](https://github.com/samskivert/jmustache) library.\n\n[![Clojars Project](https://img.shields.io/clojars/v/com.github.strojure/jmustache.svg)](https://clojars.org/com.github.strojure/jmustache)\n\n## Features\n\n- Fetch context data from Clojure persistent maps with keyword keys.\n- `:throw-missing?` compiler option to catch errors during development.\n- Easy declaration of mustache lambdas.\n- Fast rendering of templates.\n\n## Usage\n\n```clojure\n(ns readme.usage\n  (:require [strojure.jmustache.core :as jmustache]))\n\n(def ^:private my-source\n  \"\nHello {{name}}\nYou have just won {{value}} dollars!\n{{#in-ca}}\nWell, {{taxed-value}} dollars, after taxes.\n{{/in-ca}}\n  \")\n\n(def ^:private my-context\n  {:name \"Chris\",\n   :value 10000,\n   :taxed-value (- 10000 (* 10000 0.4)),\n   :in-ca true})\n\n\n;;; Ad-hoc render template.\n\n(-\u003e (jmustache/mustache-compiler)\n    (jmustache/execute-source my-source my-context)\n    (print))\n\n;Hello Chris\n;You have just won 10000 dollars!\n;Well, 6000.0 dollars, after taxes.\n\n(-\u003e (jmustache/mustache-compiler)\n    (jmustache/execute-source my-source my-context))\n#_=\u003e \"\\nHello Chris\\nYou have just won 10000 dollars!\\nWell, 6000.0 dollars, after taxes.\\n  \"\n\n;Evaluation count : 197880 in 6 samples of 32980 calls.\n;             Execution time mean : 3,163926 µs\n;    Execution time std-deviation : 283,878514 ns\n;   Execution time lower quantile : 2,934028 µs ( 2,5%)\n;   Execution time upper quantile : 3,561389 µs (97,5%)\n;                   Overhead used : 7,600431 ns\n\n\n;;; Render pre-compiled template.\n\n(def ^:private compile-fn\n  (jmustache/execute-source-fn (jmustache/mustache-compiler) my-source))\n\n(compile-fn my-context)\n#_=\u003e \"\\nHello Chris\\nYou have just won 10000 dollars!\\nWell, 6000.0 dollars, after taxes.\\n  \"\n\n;Evaluation count : 780606 in 6 samples of 130101 calls.\n;             Execution time mean : 807,030899 ns\n;    Execution time std-deviation : 21,954802 ns\n;   Execution time lower quantile : 779,365854 ns ( 2,5%)\n;   Execution time upper quantile : 834,735336 ns (97,5%)\n;                   Overhead used : 7,600431 ns\n\n\n;;; Context map with string keys using default fetcher.\n\n(def ^:private my-context-strs\n  {\"name\" \"Chris\",\n   \"value\" 10000,\n   \"taxed-value\" (- 10000 (* 10000 0.4)),\n   \"in-ca\" true})\n\n(-\u003e (jmustache/mustache-compiler :map-fetcher nil)\n    (jmustache/execute-source my-source my-context-strs)\n    (print))\n\n;Hello Chris\n;You have just won 10000 dollars!\n;Well, 6000.0 dollars, after taxes.\n\n\n;;; Context map with string and keyword keys.\n\n(def ^:private my-context-mixed\n  {:name \"Chris\",\n   \"value\" 10000,\n   \"taxed-value\" (- 10000 (* 10000 0.4)),\n   :in-ca true})\n\n(-\u003e (jmustache/mustache-compiler :map-fetcher (jmustache/mixed-map-fetcher))\n    (jmustache/execute-source my-source my-context-mixed)\n    (print))\n\n;Hello Chris\n;You have just won 10000 dollars!\n;Well, 6000.0 dollars, after taxes.\n\n\n;;; Throw exception about missing values.\n\n(-\u003e (jmustache/mustache-compiler :throw-missing? true)\n    (jmustache/execute-source my-source (dissoc my-context :name)))\n\n;Execution error (MustacheException$Context) at com.samskivert.mustache.Template/checkForMissing (Template.java:344).\n;No method or field with name 'name' on line 2\n\n(-\u003e (jmustache/mustache-compiler :throw-missing? false)\n    (jmustache/execute-source my-source (dissoc my-context :name))\n    (print))\n\n;Hello \n;You have just won 10000 dollars!\n;Well, 6000.0 dollars, after taxes.\n```\n## Q\u0026A\n\n### What's the difference to https://github.com/fhd/clostache?\n\nJava implementations offer much better performance than clostache.  \nThe https://github.com/spullara/mustache.java is fast and has adapter but behaves buggy in my use cases.  \nProbably there are some feature differences between clostache and jmustache.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrojure%2Fjmustache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrojure%2Fjmustache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrojure%2Fjmustache/lists"}