Crates.io | yew_prism |
lib.rs | yew_prism |
version | 0.4.2 |
source | src |
created_at | 2020-04-18 12:58:49.042272 |
updated_at | 2021-06-15 00:39:01.220538 |
description | Yew Prism is a highlighter code component based in Prism for yew |
homepage | https://github.com/spielrs/yew_prism.git |
repository | https://github.com/spielrs/yew_prism.git |
max_upload_size | |
id | 231506 |
size | 7,677 |
Yew Prism
Yew Prism is a highlighter code component based in Prism for yew
Install the prismjs
node module
npm install prismjs
Import the prismjs module and styles, and all the languages component which you want to use for highlighting, in your javascript/typescript main file yew project
import 'prismjs/themes/prism.css';
import 'prismjs';
import 'prismjs/components/prism-markup';
import 'prismjs/components/prism-rust';
import module from '../crate/Cargo.toml';
module.run();
Note: You can use yew-parcel-template or another template described here to create a yew project
[dependencies]
yew = { version = "0.17", features = ["web_sys"]}
yew_prism="0.4"
use yew::prelude::*;
use yew_prism::Prism;
pub struct App;
impl Component for App {
type Message = ();
type Properties = ();
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
App {}
}
fn update(&mut self, _: Self::Message) -> ShouldRender {
false
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
false
}
fn view(&self) -> Html {
html! {
<Prism
code="let greeting: &str = \"Hello World\";"
language="rust"
/>
}
}
}