Dojang is a Html template engine, as a drop in replacement for EJS. Though it does not supports 100% of the javascript syntax, it supports enough to cover the basic usages.
``` use dojang::Dojang; use serde_json::Value;
let template = "<% if a == 1 { %> Hi <% } else { %><%= a %><% } %>";
// Create a template engine Dojang. let mut dojang = Dojang::new();
// Add a template file. assert!(dojang.add("sometemplate", template).isok());
// Render a template. Note that the context should be provided as a serdejson value. asserteq!( dojang .render( "sometemplate", serdejson::from_str(r#"{ "a" : 1 }"#).unwrap() ) .unwrap(), " Hi " );
asserteq!( dojang .render( "sometemplate", serdejson::fromstr(r#"{ "a" : 2 }"#).unwrap() ) .unwrap(), "2" ); ```