2 unstable releases

Uses new Rust 2024

0.2.0 May 16, 2025
0.1.0 Mar 28, 2025

#19 in #template-rendering

Download history 13/week @ 2025-05-21 16/week @ 2025-05-28 31/week @ 2025-06-11 9/week @ 2025-06-18 13/week @ 2025-06-25 17/week @ 2025-07-02 18/week @ 2025-07-09 5/week @ 2025-07-16 39/week @ 2025-07-23 7/week @ 2025-07-30 15/week @ 2025-08-06 258/week @ 2025-08-13 66/week @ 2025-08-20 67/week @ 2025-08-27 33/week @ 2025-09-03

427 downloads per month
Used in akari

GPL-3.0-or-later

7KB
132 lines

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::Value; 

let json = r#"{"key": "value", "number": 42, "list": [1, 2, 3]}"#; 
let obj = Value::from_json(json).expect("Failed to parse JSON"); 
let dir = "D://test/test.json"; 
Value::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

Contributing

You are free to contribute!

Read more in STYLE.md

Update log

0.2.4: is_<type> functions such as is_dict() and so on implemented. New contains() function implemented

0.2.3: Debug, change Value::Dictionary into Value::Dict, Updated Macro

0.2.3-rc1: Rename Akari's method & Seperate Object mods and Template mod. Change the name of Object into Value

0.2.2: Debug insert and inheretance of templates

0.2.2-rc1: Enabled template caching, keyword "insert" now in used to insert another template into a template

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
~38K SLoC