pub struct Unreact { /* private fields */ }Expand description
Unreact app
Create a new app with Unreact::new()
TODO Examples
Implementations§
source§impl Unreact
impl Unreact
sourcepub fn new(config: Config, is_dev: bool, url: &str) -> Result<Self, Error>
pub fn new(config: Config, is_dev: bool, url: &str) -> Result<Self, Error>
Create a new empty Unreact app
Parameters
config: Configuration for the app (SeeConfig)is_dev: Whether the app should build in dev mode (Seeis_dev)url: The url that should be given to rendered templates. Overridden in dev mode
TODO Examples
sourcepub fn globalize(&mut self, data: Object) -> &mut Self
pub fn globalize(&mut self, data: Object) -> &mut Self
Set global variables for templates
TODO Examples
sourcepub fn route(&mut self, path: &str, template: &str, data: Object) -> &mut Self
pub fn route(&mut self, path: &str, template: &str, data: Object) -> &mut Self
Create a route
Parameters
path: The folder (relative to build directory) that file should be written in ({build}/{path}/index.html)template: The name of the template to usedata: Data to pass into the template, as anObject
TODO Examples
sourcepub fn route_raw(&mut self, path: &str, content: String) -> &mut Self
pub fn route_raw(&mut self, path: &str, content: String) -> &mut Self
Create a route, with raw page content instead of a template
Parameters
path: The folder (relative to build directory) that file should be written in ({build}/{path}/index.html)content: The raw file contents to write to the file
TODO Examples
sourcepub fn route_bare(&mut self, path: &str, template: &str) -> &mut Self
pub fn route_bare(&mut self, path: &str, template: &str) -> &mut Self
Create a route without any data given to the template
Parameters
path: The folder (relative to build directory) that file should be written in ({build}/{path}/index.html)template: The name of the template to use
TODO Examples
sourcepub fn index(&mut self, template: &str, data: Object) -> &mut Self
pub fn index(&mut self, template: &str, data: Object) -> &mut Self
Create the index route
Alias of app.route("", ...)
File is written to {build}/index.html
Parameters
template: The name of the template to usedata: Data to pass into the template, as anObject
TODO Examples
sourcepub fn not_found(&mut self, template: &str, data: Object) -> &mut Self
pub fn not_found(&mut self, template: &str, data: Object) -> &mut Self
Create the 404 route
Alias of app.route("404", ...).
Used as the 404 page, for a path not found
File is written to {build}/404/index.html
Parameters
template: The name of the template to usedata: Data to pass into the template, as anObject
TODO Examples
sourcepub fn compile(&self) -> Result<(), Error>
pub fn compile(&self) -> Result<(), Error>
Compile app to build directory
Does not open a dev server, even in dev mode
TODO Examples
sourcepub fn run(&self) -> Result<(), Error>
pub fn run(&self) -> Result<(), Error>
Compile app to build directly, and open local server if dev mode is active
Only opens a dev server with the "dev" or "watch" features enabled
If the "watch" feature is enabled, source files will also be watched for changes, and the client will be reloaded automatically
TODO Examples