Expand description
Specialization for JavaScript code generation.
Examples
Basic example:
use genco::prelude::*;
let toks: js::Tokens = quote! {
function foo(v) {
return v + ", World";
}
foo("Hello");
};
assert_eq!(
vec![
"function foo(v) {",
" return v + \", World\";",
"}",
"",
"foo(\"Hello\");",
],
toks.to_file_vec()?
);
String Quoting in JavaScript
JavaScript uses c-style string quoting, with indefinitely long unicode
escape sequences. But any non-control character can be embedded directly
into the string literal (like "😊"
).
use genco::prelude::*;
let toks: js::Tokens = quote!("start π 😊 \n \x7f ÿ $ \\ end");
assert_eq!("\"start π 😊 \\n \\x7f ÿ $ \\\\ end\"", toks.to_string()?);
let toks: js::Tokens = quote!($(quoted("start π 😊 \n \x7f ÿ $ \\ end")));
assert_eq!("\"start π 😊 \\n \\x7f ÿ $ \\\\ end\"", toks.to_string()?);
Structs
Configuration for JavaScript.
Format state for JavaScript.
The import of a JavaScript type import {foo} from "module.js"
.
JavaScript language specialization.
Enums
Functions
The import of a JavaScript type import {foo} from "module.js"
.
Type Definitions
Tokens container specialization for Rust.