
Reapplies #16700 with a corrected command. Now it no longer relies on a relative path. Thanks @maxdeviant for the quick help 🙏 Release Notes: - N/A
25 lines
710 B
Rust
25 lines
710 B
Rust
use crate::PreprocessorContext;
|
|
use regex::Regex;
|
|
use std::collections::HashMap;
|
|
|
|
mod action;
|
|
mod keybinding;
|
|
|
|
pub use action::*;
|
|
pub use keybinding::*;
|
|
|
|
pub trait Template {
|
|
fn key(&self) -> &'static str;
|
|
fn regex(&self) -> Regex;
|
|
fn parse_args(&self, args: &str) -> HashMap<String, String>;
|
|
fn render(&self, context: &PreprocessorContext, args: &HashMap<String, String>) -> String;
|
|
|
|
fn process(&self, context: &PreprocessorContext, content: &str) -> String {
|
|
self.regex()
|
|
.replace_all(content, |caps: ®ex::Captures| {
|
|
let args = self.parse_args(&caps[1]);
|
|
self.render(context, &args)
|
|
})
|
|
.into_owned()
|
|
}
|
|
}
|