summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Wernick <j.wernick@eyeo.com>2021-06-24 09:50:55 +0200
committerJustin Wernick <j.wernick@eyeo.com>2021-06-24 09:50:55 +0200
commitb33ce1da07ecb094b6d9fa250899d4d2f100a12e (patch)
treee1d551167bf4fc12acf23de044308e8def404101
parenta7a313d047d792eaed02d837e0bca3bbfd95fb77 (diff)
Add "Other" templating engine
-rw-r--r--src/lib.rs8
-rw-r--r--src/links.rs4
2 files changed, 10 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index d20deb1..691e309 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -162,7 +162,12 @@ fn view(model: &Model) -> Node<Msg> {
attrs! {
At::For => "url"
},
- "URL to share"
+ match model.form.template_engine.value {
+ Ok(TemplatingEngine::None) | Err(_) => "URL to Share",
+ Ok(TemplatingEngine::Jekyll) => "Jekyll Expression for URL to Share",
+ Ok(TemplatingEngine::Other) => "Template Expression for URL to Share",
+ }
+
],
input![
attrs! {
@@ -171,6 +176,7 @@ fn view(model: &Model) -> Node<Msg> {
At::Placeholder => match model.form.template_engine.value {
Ok(TemplatingEngine::None) => "https://example.com",
Ok(TemplatingEngine::Jekyll) => "page.url | absolute_url",
+ Ok(TemplatingEngine::Other) => "{{ page.url | absolute_url | cgi_escape }}",
Err(_) => ""
}
},
diff --git a/src/links.rs b/src/links.rs
index 9e0a922..c23399a 100644
--- a/src/links.rs
+++ b/src/links.rs
@@ -9,6 +9,7 @@ pub const LINK_REL: &'static str = "nofollow noopener noreferrer";
pub enum TemplatingEngine {
None,
Jekyll,
+ Other,
}
impl Default for TemplatingEngine {
@@ -38,13 +39,14 @@ impl FromStr for TemplatingEngine {
impl TemplatingEngine {
pub fn all() -> Vec<TemplatingEngine> {
- vec![Self::None, Self::Jekyll]
+ vec![Self::None, Self::Jekyll, Self::Other]
}
pub fn encode_url(&self, url: &str) -> String {
match self {
Self::None => Url::encode_uri_component(url),
Self::Jekyll => format!("{{{{ {} | cgi_escape }}}}", url),
+ Self::Other => url.to_string(),
}
}
}