pub struct LayoutComponent {
pub json: String,
pub component: ComponentName,
pub options: HashMap<String, String>,
pub children: Vec<LayoutComponent>,
}
Expand description
A component of the layout. Essentially just a limited description of an HTML element.
Fields§
§json: String
§component: ComponentName
§options: HashMap<String, String>
§children: Vec<LayoutComponent>
Implementations§
Source§impl LayoutComponent
impl LayoutComponent
Sourcepub fn from_json_file(file: &str) -> Self
pub fn from_json_file(file: &str) -> Self
Create a LayoutComponent
from the name of a file in ./.config/layouts
.
Sourcepub fn fill(&self) -> LayoutComponent
pub fn fill(&self) -> LayoutComponent
Follow component template to get full template.
All imports are relative to ./.config/layouts
.
Sourcepub fn option(&self, k: &str, d: Option<String>) -> String
pub fn option(&self, k: &str, d: Option<String>) -> String
Get the value of an option in the options
map. Accepts a default substitute.
Sourcepub fn render(&self, user: &Profile) -> String
pub fn render(&self, user: &Profile) -> String
Render the component as HTML. Skips rendering with extra junk.
See FreeRendererTemplate
.
See LayoutComponent::render_with_junk
to include junk.
Sourcepub fn render_with_junk(
&self,
user: &Profile,
config: &Config,
profile: &Option<Box<Profile>>,
lang: &LangFile,
response_count: usize,
questions_count: usize,
followers_count: usize,
following_count: usize,
friends_count: usize,
is_following: bool,
is_following_you: bool,
relationship: RelationshipStatus,
lock_profile: bool,
disallow_anonymous: bool,
require_account: bool,
hide_social: bool,
is_powerful: bool,
is_helper: bool,
is_self: bool,
) -> String
pub fn render_with_junk( &self, user: &Profile, config: &Config, profile: &Option<Box<Profile>>, lang: &LangFile, response_count: usize, questions_count: usize, followers_count: usize, following_count: usize, friends_count: usize, is_following: bool, is_following_you: bool, relationship: RelationshipStatus, lock_profile: bool, disallow_anonymous: bool, require_account: bool, hide_social: bool, is_powerful: bool, is_helper: bool, is_self: bool, ) -> String
Render the component as HTML. Since this is a profile layout, we require
a reference to the Profile
this layout is being rendered for.
Sourcepub fn render_block(&self) -> String
pub fn render_block(&self) -> String
Render the component to block format. This format doesn’t show the fully rendered form of the layout, but instead just blocks which represent the component.
This rendering is used in the editor because it saves so many server resources. The normal rendering eats memory, as it recursively renders the same HTML template.
The only component rendered halfway normally as a block is ComponentName::Flex
components.
Sourcepub fn render_tree(&self) -> String
pub fn render_tree(&self) -> String
Render the component to tree format (using HTML <details>
).
Trait Implementations§
Source§impl AsRef<LayoutComponent> for LayoutComponent
impl AsRef<LayoutComponent> for LayoutComponent
Source§fn as_ref(&self) -> &LayoutComponent
fn as_ref(&self) -> &LayoutComponent
Source§impl Clone for LayoutComponent
impl Clone for LayoutComponent
Source§fn clone(&self) -> LayoutComponent
fn clone(&self) -> LayoutComponent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for LayoutComponent
impl Debug for LayoutComponent
Source§impl Default for LayoutComponent
impl Default for LayoutComponent
Source§impl<'de> Deserialize<'de> for LayoutComponent
impl<'de> Deserialize<'de> for LayoutComponent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for LayoutComponent
impl RefUnwindSafe for LayoutComponent
impl Send for LayoutComponent
impl Sync for LayoutComponent
impl Unpin for LayoutComponent
impl UnwindSafe for LayoutComponent
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.