9 releases
Uses new Rust 2024
new 0.2.2-rc1 | Apr 15, 2025 |
---|---|
0.2.1 | Apr 9, 2025 |
0.2.0-rc1 | Mar 28, 2025 |
0.1.3 | Mar 25, 2025 |
#413 in HTTP server
981 downloads per month
Used in 3 crates
(2 directly)
140KB
2.5K
SLoC
Akari: Easy template language & Json Implementation
install by
cargo install akari
Akari is consists of 2 components, one is Json Implementation for rust, and the second component is the template rendering language
Akari Json
Macro is used in creating Akari Json.
use akari::object;
object!({
number: 3,
string: "Hello",
array: [1, 2, 3],
object: {
a: 1,
b: 2,
c: 3
}
})
Then you can create a Json.
Where you can also use
use akari::object;
use akari::Object; // Notice the capital O meaning that Object is a struct not macro
let json = r#"{"key": "value", "number": 42, "list": [1, 2, 3]}"#;
let obj = Object::from_json(json).expect("Failed to parse JSON");
let dir = "D://test/test.json";
Object::from_jsonf(dir).unwrap_or(Object::None); // Read a json from a file
obj.into_jsonf(dir); // Write obj into the dir
While various of methods are provided to read a value in json.
Be carefun about the difference between obj.to_string()
, obj.string()
and obj.into_json()
Templating
run to render a template
akari render_string "-[ output aaa ]-" aaa=1
output: 1
Read more in starberry example to find out how to write Akari template
https://github.com/Field-of-Dreams-Studio/starberry-example/tree/main
Update log
0.2.1: Update documentations for Akari
0.2.1-rc1: Enabling getting value from the Object through one function, no need for a match statement
0.2.0: Enable json file read and write
0.2.0-rc1: Update the macro, enable using complex expression and functions in the macro
0.1.3: Important Bug Fix: Now template will not causing rendering empty HTML
0.1.2: Changed object! macro, enable nesting objects
0.1.1: Enable [] operation and . operation
0.1.0: Initial Commit
Dependencies
~1.5MB
~37K SLoC