[−][src]Module genco::lang::js
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
Config | Configuration for JavaScript. |
Format | Format state for JavaScript. |
Import | The import of a JavaScript type |
JavaScript | JavaScript language specialization. |
Enums
Any | Enum produced by AsAny::as_any() which can be used to identify and operate over a discrete language item type. |
Module | A module being imported. |
Traits
AsAny | Language-specific conversion trait implemented by all language items. |
Functions
import | The import of a JavaScript type |
Type Definitions
Tokens | Tokens container specialization for Rust. |