The
--embed
option spits out a js file instead of html.
Serve the js like any other static asset and embed it in pages
like you would a github gist.
/// A hacky way to allocate/deallocate in rust stable (`alloc::heap` is still unstable) /// rust-lang/rfcs#1974 /// https://github.com/rust-lang/rust/issues/27389 /// pub fn allocate(length: usize) -> *mut c_void { let mut v = Vec::with_capacity(length); let ptr = v.as_mut_ptr(); std::mem::forget(v); ptr } fn deallocate(ptr: *mut c_void, length: usize) { std::mem::drop(Vec::from_raw_parts(ptr, 0, length)); }
Include the script anywhere on a page and it'll render the snippet on page load:
usage<p>This was loaded from a script</p> |
<div class="embedded"> |
<script src="./example.js"></script> |
</div> |
This was loaded from a script 👇