Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ngcodex/js-generator
Generates JavaScript code from HTML or Custom tags
https://github.com/ngcodex/js-generator
dom generate-js html5 java javascript javase jsoup maven
Last synced: about 1 month ago
JSON representation
Generates JavaScript code from HTML or Custom tags
- Host: GitHub
- URL: https://github.com/ngcodex/js-generator
- Owner: NGcodeX
- License: mit
- Fork: true (osscameroon/js-generator)
- Created: 2022-10-03T13:23:26.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-17T11:03:32.000Z (5 months ago)
- Last Synced: 2024-09-29T13:05:49.933Z (about 1 month ago)
- Topics: dom, generate-js, html5, java, javascript, javase, jsoup, maven
- Language: Java
- Homepage: https://osscameroon.github.io/js-generator/
- Size: 1.32 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.api.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# API
Using [`httpie`](https://httpie.io/):
```shell
# You can also pass as many HTML content as you want
# Response will be of 'application/json' content type
http -vf :8080/convert \
extension='.js' \
contents[]='
' \
contents[]='click me, please :sob:'HTTP/1.1 200
Content-Type: application/json{
"status": "SUCCESS"
"content": [
{
"content": "const targetElement_000 = document.querySelector(`:root > body`);\r\n\r\n\r\nconst hr_000 = document.createElement('hr');\r\ntargetElement_000.appendChild(hr_000);\r\n",
"filename": "inline.0.js"
},
{
"content": "const targetElement_001 = document.querySelector(`:root > body`);\r\n\r\n\r\nconst button_000 = document.createElement('button');\r\nbutton_000.setAttribute(`disabled`, `true`);\r\nconst text_000 = document.createTextNode(`click me, please :sob:`);\r\nbutton_000.appendChild(text_000);\r\ntargetElement_001.appendChild(button_000);\r\n",
"filename": "inline.1.js"
}
]
}
```Or, give the following two files contents:
> ```json
> { "extension": ".js" } // ./multipart-options.json
> ```
>
> ```html
>
>
>
>
> ...
> ...
> ...
> ``````shell
# You can call the API with multiple **files** and at most one **options**
# Response will be of 'multipart/form-data' content type
http -vf :8080/convert/files \
'files@./sample.html;type=multipart/form-data' \
'[email protected];type=application/json'HTTP/1.1 200
Content-Type: multipart/form-data;boundary=3N0wqEqnb7AC3WD8M1cYYG-vLfHDND_JdE90--3N0wqEqnb7AC3WD8M1cYYG-vLfHDND_JdE90
Content-Disposition: form-data; name="0.sample.html.js"
Content-Type: application/octet-stream
Content-Length: 4156const targetElement_000 = document.querySelector(`:root > body`);
[... truncated for brievity]
```---
After starting the `jsgenerator-api` as described in the [README.md](./README.md), you can read:
+ OpenAPI spec. at: [http://localhost:8080/openapi.yaml](http://localhost:8080/openapi.yaml)
+ OpenAPI UI at: [http://localhost:8080](http://localhost:8080)Two endpoints are exposed:
+ `POST /convert`
+ `POST /convert/files`Both accept options as follow:
```json
{
"targetElementSelector": ":root > body",
"pattern": "inline-filename-pattern",
"variableNameStrategy": "TYPE_BASED",
"variableDeclaration": "LET",
"extension": ".extension",
"contents": [
"string"
]
}
```
> **NOTE:** The `"content"` field is mandatory for `POST /convert` and forbidden for `POST /convert/files`