pub struct PageOptions {
pub elements: FnvHashMap<String, String>,
}
Expand description
Options for rendering a page template.
This struct contains the options for rendering a page template.
These options are used to construct a context FnvHashMap
that is
passed to the render_template
function.
Fields§
§elements: FnvHashMap<String, String>
Elements of the page
Implementations§
Source§impl PageOptions
impl PageOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new PageOptions
instance.
§Examples
use staticweaver::engine::PageOptions;
let options = PageOptions::new();
assert!(options.elements.is_empty());
Sourcepub fn set(&mut self, key: String, value: String)
pub fn set(&mut self, key: String, value: String)
Sets a page option in the elements
map.
§Arguments
key
- The key for the option.value
- The value for the option.
§Examples
use staticweaver::engine::PageOptions;
let mut options = PageOptions::new();
options.set("title".to_string(), "My Page".to_string());
assert_eq!(options.get("title"), Some(&"My Page".to_string()));
Sourcepub fn get(&self, key: &str) -> Option<&String>
pub fn get(&self, key: &str) -> Option<&String>
Retrieves a page option from the elements
map.
§Arguments
key
- The key of the option to retrieve.
§Returns
An Option
containing a reference to the value if the key exists,
or None
if it doesn’t.
§Examples
use staticweaver::engine::PageOptions;
let mut options = PageOptions::new();
options.set("title".to_string(), "My Page".to_string());
assert_eq!(options.get("title"), Some(&"My Page".to_string()));
assert_eq!(options.get("nonexistent"), None);
Trait Implementations§
Source§impl Clone for PageOptions
impl Clone for PageOptions
Source§fn clone(&self) -> PageOptions
fn clone(&self) -> PageOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PageOptions
impl Debug for PageOptions
Source§impl Default for PageOptions
impl Default for PageOptions
Source§fn default() -> PageOptions
fn default() -> PageOptions
Returns the “default value” for a type. Read more
Source§impl PartialEq for PageOptions
impl PartialEq for PageOptions
impl Eq for PageOptions
impl StructuralPartialEq for PageOptions
Auto Trait Implementations§
impl Freeze for PageOptions
impl RefUnwindSafe for PageOptions
impl Send for PageOptions
impl Sync for PageOptions
impl Unpin for PageOptions
impl UnwindSafe for PageOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.