microsoft_fast_convert/lib.rs
1//! # microsoft-fast-convert
2//!
3//! Converts one FAST declarative HTML `<f-template>` string into either WebUI
4//! prerelease template HTML or FAST v3 TypeScript template source. The converter
5//! uses a focused hand scanner rather than constructing a DOM or depending on an
6//! HTML parser.
7
8mod converter;
9mod error;
10mod expression;
11mod html;
12mod syntax;
13#[cfg(target_arch = "wasm32")]
14mod wasm;
15
16pub use error::ConvertError;
17pub use syntax::SyntaxMetadata;
18
19/// Convert a FAST declarative template string to the requested syntax.
20///
21/// Supported syntax values are `webui-prerelease` and `fast-v3-ts`.
22pub fn convert_template(template: &str, syntax: &str) -> Result<String, ConvertError> {
23 converter::convert(template, syntax)
24}
25
26/// Metadata for all supported converter syntax targets.
27pub fn syntax_metadata() -> &'static [SyntaxMetadata] {
28 syntax::syntax_metadata()
29}
30
31/// JSON metadata for supported converter syntax targets.
32///
33/// This is intentionally hand-written to avoid adding a serialization
34/// dependency to the crate.
35pub fn syntax_metadata_json() -> String {
36 syntax::syntax_metadata_json()
37}