https://github.com/atypicalim/pure-js-tools
pure js tools like template, query, markdown ...
https://github.com/atypicalim/pure-js-tools
javascript js template
Last synced: 9 months ago
JSON representation
pure js tools like template, query, markdown ...
- Host: GitHub
- URL: https://github.com/atypicalim/pure-js-tools
- Owner: Atypicalim
- Created: 2022-02-11T16:37:54.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-24T17:17:20.000Z (over 1 year ago)
- Last Synced: 2025-02-07T12:14:09.634Z (11 months ago)
- Topics: javascript, js, template
- Language: JavaScript
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
### Pure JS Tools
0. About
> there are some useful tools for js, u can link them with script tag and enjoy the tools ...
1. template
```javascript
var template = `template test, hello <% this.name %> ...`;
var renderer = template2renderer(template);
var html = renderer({name: "someone",});
console.log(html);
// template test, hello someone ...
```
2. query
```javascript
var $ = query2selector();
var obj = $("div");
obj.style("color", "blue");
```
3. markdown
```javascript
var mark = "## title text";
var html = markdown2html(mark);
console.log(html);
//
title text
```
4. style
```javascript
var style = {
color: "{0}",
font_size: "{1}px",
}
let renderer = style2renderer(style);
let text = renderer("#00ff00", 16);
console.log(text);
// color: #00ff00; font-size: 16px
```
5. State
```javascript
let state = new State((prxy, isWrite, key) => {
console.log("changed:", isWrite, key);
})
let proxy = state({
a: "aaa",
b: {c: "ccc"}
});
console.log("before:", proxy.b.c());
proxy.b.c = "c..."
console.log("after:", proxy.b.c());
// changed: false b.c
// before: ccc
// changed: true b.c
// changed: false b.c
// after: c...
```
---
> for more feture plz read the source code ...