{"id":22394606,"url":"https://github.com/redraiment/jssp","last_synced_at":"2025-07-31T10:32:54.749Z","repository":{"id":61157197,"uuid":"47611916","full_name":"redraiment/jssp","owner":"redraiment","description":"A templating system that embeds JVM scripting language into a text document.","archived":true,"fork":false,"pushed_at":"2022-10-15T11:43:28.000Z","size":175,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-26T22:45:52.665Z","etag":null,"topics":["beanshell","clojure","groovy","java","javascript","jruby"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/redraiment.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":"2015-12-08T09:25:21.000Z","updated_at":"2024-07-10T01:21:44.000Z","dependencies_parsed_at":"2022-10-11T23:26:18.241Z","dependency_job_id":null,"html_url":"https://github.com/redraiment/jssp","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/redraiment/jssp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redraiment%2Fjssp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redraiment%2Fjssp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redraiment%2Fjssp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redraiment%2Fjssp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redraiment","download_url":"https://codeload.github.com/redraiment/jssp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redraiment%2Fjssp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268024659,"owners_count":24183149,"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","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["beanshell","clojure","groovy","java","javascript","jruby"],"created_at":"2024-12-05T05:11:04.639Z","updated_at":"2025-07-31T10:32:54.384Z","avatar_url":"https://github.com/redraiment.png","language":"Clojure","readme":"# JVM Scripting Server Pages\n\n[![Clojure CI](https://github.com/redraiment/jssp/actions/workflows/clojure.yml/badge.svg)](https://github.com/redraiment/jssp/actions/workflows/clojure.yml)\n\nJVM Scripting Server page (also shortened as JSSP) is a polyglot templating system that embeds JVM scripting language into a text document, similar to JSP, PHP, ASP, and other server-side scripting languages.\n\n# Getting Started with Docker\n\n```sh\ndocker run --rm redraiment/jssp\n```\n\n# Tutorial\n\n## Basic Example\n\nHere is a basic example of JSSP.\n\n```sh\ndocker run --rm -v $PWD:/jssp redraiment/jssp \\\n  examples/local-mode/languages.md.groovy\n```\n\n*Template*: examples/local-mode/languages.md.groovy\n\n```groovy\n# Languages\n\n[! [\"JavaScript\", \"Groovy\", \"JRuby\", \"BeanShell\"].each { !]\n* [= it =]\n[! } !]\n```\n\n*Output*\n\n```markdown\n# Languages\n\n* JavaScript\n* Groovy\n* JRuby\n* BeanShell\n```\n\n## Multi-Language Support\n\nJSSP supports the following languages:\n\n* JavaScript\n* Groovy\n* BeanShell (Java)\n* JRuby (Ruby)\n\n*JavaScript Template*: examples/local-mode/languages.md.js\n\n```js\n[! var languages = ['JavaScript', 'Groovy', 'JRuby', 'BeanShell'] !]\n# Languages\n\n[! for (var index = 0; index \u003c languages.length; index++) { !]\n* [= languages[index] =]\n[! } !]\n```\n\n*Groovy Template*: examples/local-mode/languages.md.groovy\n\n```groovy\n# Languages\n\n[! [\"JavaScript\", \"Groovy\", \"JRuby\", \"BeanShell\"].each { !]\n* [= it =]\n[! } !]\n```\n\n*BeanShell Template*: examples/local-mode/languages.md.bsh\n\n```java\n[! String[] languages = new String[] { \"JavaScript\", \"Groovy\", \"JRuby\", \"BeanShell\" } !]\n# Languages\n\n[! for (String language : languages) { !]\n* [= language =]\n[! } !]\n```\n\n*JRuby Template*: examples/local-mode/languages.md.rb\n\n```ruby\n# Languages\n\n[! [\"JavaScript\", \"Groovy\", \"JRuby\", \"BeanShell\"].each do |language| !]\n* [= language =]\n[! end !]\n```\n\n## Trimming Spaces\n\nJSSP deletes spaces around statement patterns (`[! !]` and `@! !@`) automatically, while it leaves spaces around expression patterns (`[= =]` and `@= =@`). If you want leave spaces, add command-line option `--trim=false`.\n\n```sh\ndocker run --rm -v $PWD:/jssp redraiment/jssp \\\n  --trim=false \\\n  examples/local-mode/languages.md.groovy\n```\n\n*Output*\n\n```markdown\n# Languages\n\n\n* JavaScript\n\n* Groovy\n\n* JRuby\n\n* BeanShell\n\n```\n\n## Context Data File\n\nCommand-line option `-f/--context-file` specifies context data file. JSSP load context data file and use it as context data. Context data file can be JSON file (`*.json`) only.\n\n```sh\ndocker run --rm -v $PWD:/jssp redraiment/jssp \\\n  -f examples/context-data/data.json \\\n  examples/context-data/languages.md.rb\n```\n\n*Template*: examples/context-data/languages.md.rb\n\n```ruby\n# Languages\n\n[! languages.each do |language| !]\n* [= language =]\n[! end !]\n```\n\n*Context Data File*: examples/context-data/data.json\n\n```json\n{\n    \"languages\": [\n        \"JavaScript\",\n        \"Groovy\",\n        \"JRuby\",\n        \"BeanShell\"\n    ]\n}\n```\n\n*Output*:\n\n```markdown\n# Languages\n\n* JavaScript\n* Groovy\n* JRuby\n* BeanShell\n```\n\n## Context Data String\n\nCommand-line option `-c/--context-string JSON` enables you to specify JSON format context data in command-line. \n\n```sh\ndocker run --rm -v $PWD:/jssp redraiment/jssp \\\n  -c '{\"languages\": [\"JavaScript\", \"Groovy\", \"JRuby\", \"BeanShell\"]}' \\\n  examples/context-data/languages.md.rb\n```\n\n*Output*:\n\n```markdown\n# Languages\n\n* JavaScript\n* Groovy\n* JRuby\n* BeanShell\n```\n\n## Embedded Pattern\n\nYou can change embedded pattern to another.\n\n```sh\ndocker run --rm -v $PWD:/jssp redraiment/jssp \\\n  --executing-statement='\u003c!--% %--\u003e' \\\n  --executing-expression='\u003c!--= =--\u003e' \\\n  examples/embedded-patterns/languages.html.groovy\n```\n\n*Template*: examples/embedded-patterns/languages.html.groovy\n\n```html\n\u003ch1\u003eLanguages\u003c/h1\u003e\n\u003cul\u003e\n  \u003c!--% [\"JavaScript\", \"Groovy\", \"JRuby\", \"BeanShell\"].each { %--\u003e\n  \u003cli\u003e\u003c!--= it =--\u003e\u003c/li\u003e\n  \u003c!--% } %--\u003e\n\u003cul\u003e\n```\n\n*Output*:\n\n```html\n\u003ch1\u003eLanguages\u003c/h1\u003e\n\u003cul\u003e\n  \u003cli\u003eJavaScript\u003c/li\u003e\n  \u003cli\u003eGroovy\u003c/li\u003e\n  \u003cli\u003eJRuby\u003c/li\u003e\n  \u003cli\u003eBeanShell\u003c/li\u003e\n\u003cul\u003e\n```\n\n## Nested Include\n\nThere are two phases during render a template:\n\n1. Expanding phase: render repeatedly with expanding patterns, to compute another template which will in turn render, until no more patterns can be found.\n2. Executing phase: render with executing patterns once.\n\nThe `include` and `includeOnce` functions are read and return the specified file. The argument is a relative path of current working directory.\n\n```sh\ndocker run --rm -v $PWD:/jssp redraiment/jssp \\\n  examples/nested-include/index.css.groovy\n```\n\n*Template*: examples/nested-include/index.css.groovy\n\n```groovy\n@= includeOnce('examples/nested-include/colors.groovy') =@\n[! ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].each { tag -\u003e !]\n@= includeOnce('examples/nested-include/highlight.css.groovy') =@\n[! } !]\n```\n\n*Template*: examples/nested-include/highlight.css.groovy\n\n```groovy\n@= includeOnce('examples/nested-include/colors.groovy') =@\n[! colors.each { level, color -\u003e !]\n[= tag =].[= level =] {\n  color: [= color =];\n}\n[! } !]\n```\n\n*Template*: examples/nested-include/colors.groovy\n\n```groovy\n[!\n colors = [\n   normal: '#777777',\n   primary: 'blue',\n   success: 'green',\n   warning: 'yellow',\n   danger: 'red'\n ]\n!]\n```\n\n*Output*:\n\n```css\n\n\nh1.normal {\n  color: #777777;\n}\n\nh1.primary {\n  color: blue;\n}\n\n...\n\nh6.warning {\n  color: yellow;\n}\n\nh6.danger {\n  color: red;\n}\n\n```\n\n## HTTP Server\n\nRun a simple HTTP server:\n\n```sh\ncd examples/server-mode\ndocker run --rm -d -v $PWD:/jssp -p 8080:8080 redraiment/jssp -s\nhttp GET 'http://localhost:8080/index.html.groovy'\n```\n\n*Template*: examples/server-mode/index.html.groovy\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"zh-CN\"\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge\" /\u003e\n    \u003cmeta name=\"renderer\" content=\"webkit\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\" /\u003e\n    \u003ctitle\u003eHello JSSP\u003c/title\u003e\n    \u003clink rel=\"stylesheet\" href=\"styles/index.css.js\" /\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003eHello JVM Scripting Server Pages\u003c/h1\u003e\n    \u003cdl\u003e\n      [! request.each { key, value -\u003e !]\n      \u003cdt\u003e[= escape(key) =]\u003c/dt\u003e\n      \u003cdd\u003e[= escape(value) =]\u003c/dd\u003e\n      [! } !]\n    \u003c/dl\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n*Template*: examples/server-mode/styles/index.css.js\n\n```css\n[!\n var backgroundColor = 'lavender';\n var foregroundColor = 'blue';\n var fontSize = 12;\n\n var em = function(size) {\n     if (arguments.length === 0) {\n         size = 1.0;\n     }\n     return Math.floor(fontSize * size) + 'px';\n };\n!]\n\nbody {\n    background-color: [= backgroundColor =];\n    color: [= foregroundColor =];\n    font-size: [= em() =];\n}\n\ndt {\n    font-size: [= em(1.5) =];\n}\n```\n\n*Output*:\n\n![ScreenShot](https://github.com/redraiment/jssp/blob/main/examples/server-mode/images/screenshot.png)\n\n# Command Reference\n\n## Usage\n\nOutside mode: to produce a static document offline:\n\n```sh\njssp [options] TEMPLATE-FILE\n```\n\nServer-side mode: to run the inner web server:\n\n```sh\njssp [-s | --server] [options]\n```\n\n## Options\n\n* `-c, --context-string JSON`: context data string in JSON format, default `{}`.\n* `-f, --context-file JSON-FILE`: context data JSON file name, it will override context data string above.\n* `-t, --trim BOOLEAN`: switch to delete spaces around statement, default `true`.\n* `--expanding-statement PATTERN`: expanding statement pattern, default `@! !@`.\n* `--expanding-expression PATTERN`: expanding expression pattern, default `@= =@`.\n* `--executing-statement PATTERN`: executing statement pattern, default `[! !]`.\n* `--executing-expression PATTERN`: executing expression pattern, default `[= =]`.\n* `-m, --expand-limit TIMES`: set the limit times for expanding phase, it's infinite if not provides.\n* `-x, --emit-code`: emit expanded code.\n* `-s, --server`: start inner http server.\n* `-p, --port PORT`: http server port, default 8080.\n* `-h, --help`: show help and exit.\n\n## Built-in Functions\n\n### include\n\nThe `include` function reads and returns the content of specified file.\n\nIt usually used with expanding expression pattern to include a shared fragment context into current template.\n\n### includeOnce\n\nThe `includeOnce` function is identical to `include` except JSSP will check if the file has already been included, and if so, not include it again.\n\n### escape\n\nThe `escape` function escapes the characters in a String using HTML entities.\n\n# Contributing\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\". Don't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n1. Create your Feature Branch (git checkout -b feature/AmazingFeature)\n1. Commit your Changes (git commit -m 'Add some AmazingFeature')\n1. Push to the Branch (git push origin feature/AmazingFeature)\n1. Open a Pull Request\n\n# License\n\nDistrubuted under the Apache v2 License. See `LICENSE` for more information.\n\n# Contact\n\n* Zhang, Zepeng - [@redraiment](https://twitter.com/redraiment) - [redraiment@gmail.com](mailto:redraiment@gmail.com)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredraiment%2Fjssp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredraiment%2Fjssp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredraiment%2Fjssp/lists"}