The lasso-marko plugin for Lasso.js will automatically compile all imported Marko templates during bundling. In addition, the
lasso-marko plugin will automatically bundle any template dependencies (including required CSS).
The sample marko-lasso app demonstrates how to build a production-ready web application using Marko and Lasso.
npm install lasso-marko --save
npm install lasso-markonpm install @lasso/marko-taglib
After installing, the lasso custom tags can be used in your templates:
Marko + Lasso
Lasso.js will automatically bundle up transitive dependencies by building and walking a dependency graph.
When Lasso.js bundles up the code above it will automatically bundle up the required
If you are rendering the initial UI on the server then it is necessary to make sure that all UI components are bundled and sent to the browser so that UI components can be mounted in the browser. For example:
<html lang="en"><head><meta charset="UTF-8"><title>Marko + Lasso</title><!-- CSS will be inserted here --><lasso-head/></head><body><!-- Top-level UI component: --><app/><!-- JS will be inserted here --><lasso-body/></body></html>
html lang="en"headmeta charset="UTF-8"title -- Marko + Lasso// CSS will be inserted herelasso-headbody// Top-level UI component:app// JS will be inserted herelasso-body
browser-refresh is recommended in development for instant page refreshes and hot reloading of Marko templates, styles and other resources.
browser-refresh works well with Lasso and Marko and is very easy to use as a drop-in replacement for
For many use cases, the combination of
@lasso/marko-taglib is sufficient to render and bundle components without the need for explicit
browser.json files. For more advanced use cases, the following bundle types may be defined in a
browser.json for Lasso.
marko-dependencies: (provided by
lasso-marko) Includes all the dependencies needed by template and the code to register all components that would be rendered by the template. It does not automatically initialize the component, so is most useful if you need to initialize components manually.
"type": "marko-dependencies""path": "src/ui-modules/outdated-browser-banner/index.marko"
Note: To initialize the server rendered components, there are 2 steps:
Step 1: Manually retrieve server rendered components, shipped via
To retrieve the list of server rendered components, do:
marko-hydrate: (provided by
lasso-marko) Includes all the dependencies needed by template and the code to register all components that would be rendered by the template. This also includes the code to initialize the rendered components. Including this bundle on the page will automatically hydrate server rendered components.
"type": "marko-hydrate""path": "src/ui-modules/outdated-browser-banner/index.marko"
marko-hydrate will initialize the component if its defined on the global
window.$components which is inserted by
Marko when it sees a
<body> tag. Else, if you are just rendering out and lasso-ing the a portion of a page with a set of components, include
<init-components/> at the end of the associated
template.marko file that builds out the page fragment.
package: A collection of dependencies.
browser.json is the most common package type. It could be used to point to another
browser.json from within one component's
browser.json. Typically also used when the dependencies of the referred
browser.json have to be packaged inline.
"type": "package""path": "src/ui-modules/show-diag/browser.json"
"type": "require""path": "src/ui-modules/dynamic-module-loader/dynamic-init-client.js"
EDIT"run": true"type": "require""path": "src/ui-modules/my-module/init.js"
Helpful? You can thank these awesome people! You can also edit this doc if you see any issues or want to improve it.