### Rendering HTML Template with Luminus Layout (Clojure)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/core/resources/docs.md
This `home-page` function renders the `home.html` template using the `layout/render` function. It passes the request object and a map containing the `:docs` key, which holds the content of `resources/docs/docs.md`, for dynamic content injection.
```Clojure
(defn home-page [request]
(layout/render
request
"home.html" {:docs (-> "docs/docs.md" io/resource slurp)}))
```
--------------------------------
### Defining Home Routes in Luminus (Clojure)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/core/resources/docs.md
This snippet defines the `home-routes` handler, mapping HTTP GET requests for the root URI (`/`) to the `home-page` function and `/about` to `about-page`. It applies CSRF protection and format serialization/deserialization middleware to these routes.
```Clojure
(defn home-routes []
[""
{:middleware [middleware/wrap-csrf
middleware/wrap-formats]}
["/" {:get home-page}]
["/about" {:get about-page}]])
```
--------------------------------
### Starting Web Server with Boot (Clojure)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/core/README.md
This command starts the web server for the Luminus application using Boot, another build tool for Clojure. It is used when the project is configured to use Boot instead of Leiningen.
```Shell
boot run
```
--------------------------------
### Starting Web Server with Leiningen (Clojure)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/core/README.md
This command starts the web server for the Luminus application using Leiningen, a build automation tool for Clojure projects. It is used when the project is configured to use Leiningen.
```Shell
lein run
```
--------------------------------
### Aggregating Application Routes and Middleware (Clojure)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/core/resources/docs.md
This `mount/defstate` snippet defines the main `app` handler, which aggregates all application routes, including `home-routes`, and applies base middleware. It also sets up default handlers for common HTTP errors like 404, 405, and 406, providing custom error pages.
```Clojure
(mount/defstate app
:start
(middleware/wrap-base
(ring/ring-handler
(ring/router
[(home-routes)])
(ring/routes
(ring/create-resource-handler
{:path "/"})
(wrap-content-type
(wrap-webjars (constantly nil)))
(ring/create-default-handler
{:not-found
(constantly (error-page {:status 404, :title "404 - Page not found"}))
:method-not-allowed
(constantly (error-page {:status 405, :title "405 - Not allowed"}))
:not-acceptable
(constantly (error-page {:status 406, :title "406 - Not acceptable"}))})))))
```
--------------------------------
### Generating ClojureScript Compiler Instructions (Luminus Template)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/cljs/resources/html/home.html
This template block dynamically generates instructions for starting the ClojureScript compiler. It adapts the command based on whether 'boot' or 'shadow-cljs' is configured, guiding the user to run 'shadow-cljs watch app', 'lein figwheel', or 'boot figwheel' to enable live compilation and page reloading.
```Templating Language
<% if not boot %>
Please run `<% if shadow-cljs %>shadow-cljs watch app<% else %>lein figwheel<% endif %>` to start the ClojureScript compiler and reload the page.
<% else %>
Please close this process and start the server with `boot figwheel` to enable the ClojureScript compiler.<% endif %>
```
--------------------------------
### Selmer HTML Template for Markdown Content
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/core/resources/docs.md
This HTML snippet demonstrates a basic Selmer template structure. It uses the `{{docs|markdown}}` tag to inject and render the content associated with the `docs` parameter (which is markdown) directly into the `div` element, leveraging Selmer's markdown filter.
```HTML
```
--------------------------------
### Rendering Home Page HTML in Luminus (ClojureScript)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/expanded/resources/docs.md
This Clojure function is responsible for rendering the `home.html` template. It takes a `request` object and uses the `layout/render` function to generate the HTML response, typically for the main application page. This is specific to the ClojureScript enabled setup.
```Clojure
(defn home-page [request]
(layout/render request "home.html"))
```
--------------------------------
### Creating Luminus Project with Multiple Profiles (Bash)
Source: https://github.com/luminus-framework/luminus-template/blob/master/README.md
This example illustrates how to create a new Luminus application, 'myapp', while simultaneously incorporating multiple profiles. Here, '+auth' adds authentication features, and '+postgres' configures PostgreSQL database support, showcasing the flexibility of profile mixing.
```bash
lein new luminus myapp +auth +postgres
```
--------------------------------
### Defining Home Routes in Luminus (Clojure)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/expanded/resources/docs.md
This Clojure function defines the main routes for a Luminus application without ClojureScript. It applies middleware for CSRF protection and format handling, mapping the root path '/' to `home-page` and '/about' to `about-page`. This setup is typical for server-side rendered applications.
```Clojure
(defn home-routes []
[""
{:middleware [middleware/wrap-csrf
middleware/wrap-formats]}
["/" {:get home-page}]
["/about" {:get about-page}]])
```
--------------------------------
### Defining Home Routes with ClojureScript in Luminus
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/expanded/resources/docs.md
This Clojure function defines the main routes for a Luminus application when ClojureScript is enabled. It sets up middleware for CSRF protection and format handling, maps the root path '/' to `home-page`, and provides a route for '/docs' to serve documentation as plain text. It uses `response/ok` and `response/header` for serving resources.
```Clojure
(defn home-routes []
[""
{:middleware [middleware/wrap-csrf
middleware/wrap-formats]}
["/" {:get home-page}]
["/docs" {:get (fn [request]
(-> (response/ok (-> "docs/docs.md" io/resource slurp))
(response/header "Content-Type" "text/plain; charset=utf-8")))}]])
```
--------------------------------
### Creating a New Luminus Project with Leiningen (Bash)
Source: https://github.com/luminus-framework/luminus-template/blob/master/README.md
This command initializes a new Luminus project using the default template. It requires Leiningen to be installed and available in the system's PATH. Replace '' with the desired name for your new application. This creates a basic Luminus project structure.
```Bash
lein new luminus
```
--------------------------------
### Parsing URL Search Parameters in JavaScript
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/graphql/resources/html/graphiql.html
This JavaScript snippet parses the `window.location.search` string to extract URL parameters into a `parameters` object. It iterates through key-value pairs, decodes them using `decodeURIComponent`, and stores them, enabling the application to read initial state from the URL.
```JavaScript
var search = window.location.search;
var parameters = {};
search.substr(1).split('&').forEach(function (entry) {
var eq = entry.indexOf('=');
if (eq >= 0) {
parameters[decodeURIComponent(entry.slice(0, eq))] = decodeURIComponent(entry.slice(eq + 1));
}
});
```
--------------------------------
### Rendering Home Page with Docs Content in Luminus (Clojure)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/expanded/resources/docs.md
This Clojure function renders the `home.html` template, passing the content of `docs/docs.md` as a `:docs` parameter. It uses `layout/render` to combine the request, template, and data, allowing dynamic content injection into the HTML. This is used when ClojureScript is not enabled.
```Clojure
(defn home-page [request]
(layout/render
request
"home.html" {:docs (-> "docs/docs.md" io/resource slurp)}))
```
--------------------------------
### Aggregating Application Routes and Handlers in Luminus
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/expanded/resources/docs.md
This Clojure code defines the main application handler (`app-routes`) using `mount/defstate` for lifecycle management. It aggregates `home-routes` with resource handlers for static files and webjars, and includes a default handler for common HTTP errors like 404, 405, and 406. This structure ensures all routes and static assets are served correctly.
```Clojure
(mount/defstate app-routes
:start
(ring/ring-handler
(ring/router
[(home-routes)])
(ring/routes
(ring/create-resource-handler
{:path "/"})
(wrap-content-type
(wrap-webjars (constantly nil)))
(ring/create-default-handler
{:not-found
(constantly (error-page {:status 404, :title "404 - Page not found"}))
:method-not-allowed
(constantly (error-page {:status 405, :title "405 - Not allowed"}))
:not-acceptable
(constantly (error-page {:status 406, :title "406 - Not acceptable"}))}))))
```
--------------------------------
### Defining GraphQL Fetcher for GraphiQL in JavaScript
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/graphql/resources/html/graphiql.html
This JavaScript function, `graphQLFetcher`, defines a GraphQL fetcher using the standard `fetch` API. It sends a POST request to `/api/graphql` with the provided GraphQL parameters, sets appropriate headers, and then processes the response, attempting to parse it as JSON or returning raw text on error.
```JavaScript
function graphQLFetcher(graphQLParams) {
console.log(graphQLParams);
return fetch(window.location.origin + '/api/graphql', {
method: 'post',
headers: {
'Content-Type': 'application/graphql',
'apikey': 'graphiql'
},
body: JSON.stringify(graphQLParams)
}).then(function (response) {
return response.text();
}).then(function (responseBody) {
console.log(responseBody);
try {
return JSON.parse(responseBody);
} catch (error) {
return responseBody;
}
});
}
```
--------------------------------
### Rendering GraphiQL Component with React in JavaScript
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/graphql/resources/html/graphiql.html
This JavaScript snippet uses `ReactDOM.render` to mount the `GraphiQL` React component into the `document.body`. It passes various props including the `fetcher` function, initial `query` and `variables` derived from URL parameters, and `onEditQuery`/`onEditVariables` handlers for synchronizing state with the URL.
```JavaScript
ReactDOM.render(
React.createElement(GraphiQL, {
fetcher: graphQLFetcher,
query: parameters.query,
variables: parameters.variables,
onEditQuery: onEditQuery,
onEditVariables: onEditVariables
}),
document.body
);
```
--------------------------------
### Formatting GraphiQL Variables from URL in JavaScript
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/graphql/resources/html/graphiql.html
This JavaScript snippet attempts to parse and pretty-print the `variables` parameter from the URL if it exists. It uses `JSON.parse` and `JSON.stringify` to format the JSON string, gracefully handling parsing errors by displaying the invalid JSON as a string.
```JavaScript
if (parameters.variables) {
try {
parameters.variables = JSON.stringify(JSON.parse(parameters.variables), null, 2);
} catch (e) {
// Do nothing, we want to display the invalid JSON as a string, rather
// than present an error.
}
}
```
--------------------------------
### Including ClojureScript Application in Selmer Template
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/expanded/resources/docs.md
This Selmer template tag includes the compiled ClojureScript application JavaScript file, `app.js`, into the HTML page. It ensures that the client-side logic generated by ClojureScript is loaded and executed in the browser. The script is expected to be located in the `target/cljsbuild/public` folder.
```Selmer
{% script "/js/app.js" %}
```
--------------------------------
### Styling HTML Body for Full Viewport in CSS
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/graphql/resources/html/graphiql.html
This CSS snippet sets the `html` and `body` elements to occupy 100% of the viewport height and width, removes default margins, and hides overflow. This is typically used for full-page applications or components like GraphiQL to ensure they fill the entire browser window.
```CSS
html, body { height: 100%; margin: 0; width: 100%; overflow: hidden; }
```
--------------------------------
### Computing URL Parameter String in JavaScript
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/graphql/resources/html/graphiql.html
This JavaScript function, `computeParams`, constructs a URL query string from the `parameters` object. It iterates over the object's keys, encodes both keys and values using `encodeURIComponent`, and joins them with '&' to form a valid URL segment suitable for browser history updates.
```JavaScript
function computeParams() {
return '?' + Object.keys(parameters).map(function (key) {
return encodeURIComponent(key) + '=' + encodeURIComponent(parameters[key]);
}).join('&');
}
```
--------------------------------
### Updating URL on GraphiQL Variables Edit in JavaScript
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/graphql/resources/html/graphiql.html
This JavaScript function, `onEditVariables`, serves as a callback for changes in the GraphiQL variables editor. It updates the `variables` property in the global `parameters` object and subsequently invokes `updateURL()` to synchronize the browser's URL, enabling the sharing of variable states.
```JavaScript
function onEditVariables(newVariables) {
parameters.variables = newVariables;
updateURL();
}
```
--------------------------------
### Updating Browser URL History in JavaScript
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/graphql/resources/html/graphiql.html
This JavaScript function, `updateURL`, updates the browser's URL using `history.replaceState()`. It calls `computeParams()` to generate the new URL string, effectively changing the URL without triggering a page reload, which is crucial for seamless URL sharing and state persistence.
```JavaScript
function updateURL() {
history.replaceState(null, null, computeParams());
}
```
--------------------------------
### Updating URL on GraphiQL Query Edit in JavaScript
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/graphql/resources/html/graphiql.html
This JavaScript function, `onEditQuery`, is a callback for when the GraphiQL query editor content changes. It updates the `query` property in the global `parameters` object and then calls `updateURL()` to reflect this change in the browser's URL bar, allowing for shareable query links.
```JavaScript
function onEditQuery(newQuery) {
parameters.query = newQuery;
updateURL();
}
```
--------------------------------
### Displaying Markdown Content in Selmer Template
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/expanded/resources/docs.md
This Selmer template snippet demonstrates how to display markdown content within an HTML `div` element. The `{{docs|markdown}}` expression takes the value of the `docs` variable (which contains markdown text) and renders it as HTML using Selmer's markdown filter. This allows dynamic rendering of documentation or other text content.
```Selmer
{{docs|markdown}}
```
--------------------------------
### Running Database Migrations with Leiningen
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/db/docs/db_instructions.md
This command initiates database migrations using Leiningen, which creates or updates the necessary tables for the application. It must be executed from the root directory of the project after the database connection details have been updated in the configuration files.
```Shell
lein run migrate
```
--------------------------------
### Rendering Home Page with Docs Content (Clojure)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/reitit/resources/docs.md
This Clojure function renders the `home.html` template, passing the content of `docs/docs.md` as a `:docs` parameter to the template. This allows the template to dynamically display documentation content from the `resources/docs` folder.
```Clojure
(defn home-page [request]
(layout/render
request
"home.html" {:docs (-> "docs/docs.md" io/resource slurp)}))
```
--------------------------------
### Building Luminus Project as Standalone JAR with Boot (Bash)
Source: https://github.com/luminus-framework/luminus-template/blob/master/README.md
For projects utilizing the '+boot' profile, this command leverages Boot to build the Luminus application into a standalone executable JAR file. Similar to Leiningen's 'uberjar', it creates a single, deployable artifact.
```bash
boot uberjar
```
--------------------------------
### Running Standalone Luminus JAR (Bash)
Source: https://github.com/luminus-framework/luminus-template/blob/master/README.md
This command executes the previously built standalone '.jar' file using the Java Virtual Machine. The output demonstrates the successful startup of the Luminus server, indicating that the application is running and listening on the specified port.
```bash
user$ java -jar target/myapp.jar
15-Sep-14 16:06:21 APc47d.4f39.65e6.uhn.ca INFO [myapp.handler] -
-=[myapp started successfully]=-
16:06:21.685 INFO [org.projectodd.wunderboss.web.Web] (main) Registered web context /
15-Sep-14 16:06:21 APc47d.4f39.65e6.uhn.ca INFO [myapp.core] - server started on port: 3002
```
--------------------------------
### Running Database Migrations with Leiningen
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/db/docs/h2_instructions.md
This command executes database migrations using Leiningen, creating the necessary tables for the application. It is a crucial prerequisite for establishing proper database access within the Luminus project.
```Shell
lein run migrate
```
--------------------------------
### Creating Luminus Project with ClojureScript Profile (Bash)
Source: https://github.com/luminus-framework/luminus-template/blob/master/README.md
This command demonstrates how to create a new Luminus project named 'myapp' and include the 'cljs' profile for ClojureScript support. Profiles are passed as arguments after the application name to customize the project's features.
```bash
lein new luminus myapp +cljs
```
--------------------------------
### Defining Home Routes with Docs Endpoint (ClojureScript)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/reitit/resources/docs.md
This Clojure function defines the application's primary routes when ClojureScript is enabled. It includes a root path ('/') handled by `home-page` and a '/docs' endpoint that serves the `docs.md` file as plain text, applying CSRF and format handling middleware.
```Clojure
(defn home-routes []
[""
{:middleware [middleware/wrap-csrf
middleware/wrap-formats]}
["/" {:get home-page}]
["/docs" {:get (fn [_]
(-> (response/ok (-> "docs/docs.md" io/resource slurp))
(response/header "Content-Type" "text/plain; charset=utf-8")))}]])
```
--------------------------------
### Building Luminus Project as Standalone JAR with Leiningen (Bash)
Source: https://github.com/luminus-framework/luminus-template/blob/master/README.md
This command uses Leiningen to package the Luminus application into a standalone executable Java ARchive (JAR) file. The 'uberjar' task bundles all dependencies, making the application self-contained and easily deployable.
```bash
lein uberjar
```
--------------------------------
### Aggregating Application Routes and Middleware (Clojure)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/reitit/resources/docs.md
This Clojure `mount/defstate` defines the main application handler, `app`, which aggregates all defined routes, applies base middleware, and sets up default error handlers for 404, 405, and 406 HTTP statuses. It uses Ring and Reitit for routing and request handling.
```Clojure
(mount/defstate app
:start
(middleware/wrap-base
(ring/ring-handler
(ring/router
[(home-routes)])
(ring/routes
(ring/create-resource-handler
{:path "/"})
(wrap-content-type
(wrap-webjars (constantly nil)))
(ring/create-default-handler
{:not-found
(constantly (error-page {:status 404, :title "404 - Page not found"}))
:method-not-allowed
(constantly (error-page {:status 405, :title "405 - Not allowed"}))
:not-acceptable
(constantly (error-page {:status 406, :title "406 - Not acceptable"}))})))))
```
--------------------------------
### Displaying Markdown Content in HTML Template (Selmer)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/reitit/resources/docs.md
This HTML snippet, utilizing the Selmer templating engine, displays the content of the `docs` variable within a Bootstrap row and column. The `|markdown` filter processes the content, converting it from Markdown to HTML before rendering.
```HTML
```
--------------------------------
### Rendering Home Page (ClojureScript)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/reitit/resources/docs.md
This Clojure function is responsible for rendering the `home.html` template. It is invoked when the root URI is accessed and uses the `layout/render` function to generate the HTML content.
```Clojure
(defn home-page [request]
(layout/render request "home.html"))
```
--------------------------------
### Defining Home and About Routes (Clojure)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/reitit/resources/docs.md
This Clojure function defines the application's primary routes when ClojureScript is not enabled. It includes a root path ('/') handled by `home-page` and an '/about' endpoint handled by `about-page`, applying CSRF and format handling middleware.
```Clojure
(defn home-routes []
[""
{:middleware [middleware/wrap-csrf
middleware/wrap-formats]}
["/" {:get home-page}]
["/about" {:get about-page}]])
```
--------------------------------
### Including Main JavaScript Application Script (Luminus Template)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/cljs/resources/html/home.html
This template directive uses `{% script %}` to include the primary application JavaScript file (`/js/app.js`). It ensures that the main client-side logic and functionality are loaded and executed on the page after other necessary variables are set up.
```Templating Language
{% script "/js/app.js" %}
```
--------------------------------
### Including Compiled ClojureScript Application (HTML Template)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/reitit/resources/docs.md
This Selmer template tag dynamically includes the compiled ClojureScript application bundle, `app.js`, into the HTML page. It ensures the client-side logic, including the rest of the page's rendering, is loaded from the `target/cljsbuild/public` folder.
```HTML
{% script "/js/app.js" %}
```
--------------------------------
### Initializing JavaScript Context and CSRF Token (Luminus Template)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/cljs/resources/html/home.html
This JavaScript snippet, embedded within the template, declares and initializes global `context` and `csrfToken` variables. The values are dynamically injected by the server-side template engine, providing essential client-side data for routing and security, conditional on the `servlet` configuration.
```JavaScript
<% if servlet %> var context = "{{servlet-context}}";<% endif %> var csrfToken = "{{csrf-token}}";
```
--------------------------------
### Stress Testing Luminus App with Apache Benchmark (Bash)
Source: https://github.com/luminus-framework/luminus-template/blob/master/README.md
This command utilizes the Apache Benchmark (ab) tool to perform a stress test on the running Luminus application. It sends 1000 requests to the specified URL with a concurrency of 10, helping to evaluate the application's performance under load.
```bash
ab -c 10 -n 1000 http://127.0.0.1:3000/
```
--------------------------------
### Conditional CSS Asset Inclusion (Luminus Template)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/cljs/resources/html/home.html
This template snippet uses `{% style %}` directives to conditionally include Bulma and Material Icons CSS, along with a base `screen.css` file. The inclusion of optional assets depends on the `expanded` flag, ensuring appropriate styling is loaded for the front-end.
```Templating Language
<% if expanded %>{% style "/assets/bulma/css/bulma.min.css" %} {% style "/assets/material-icons/css/material-icons.min.css" %} <% endif %>{% style "/css/screen.css" %}
```
--------------------------------
### Defining Luminus HTML Base Template with Conditional Image
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/expanded/resources/html/about.html
This snippet illustrates how to define a base HTML template in Luminus, extending a parent template and embedding an image. The image's source path is dynamically constructed, conditionally including a servlet context path if available, which is typical for web applications deployed in a servlet environment.
```HTML Template
{% extends "base.html" %} {% block content %}  {% endblock %}
```
--------------------------------
### Supported Leiningen Hooks for lein-sassc (Shell)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/sassc/docs/sassc_instructions.md
These are standard Leiningen hooks that `lein-sassc` integrates with. `lein compile` is used for compiling the project, and `lein clean` is for cleaning the project's build artifacts, both of which can trigger `lein-sassc` operations if configured.
```Shell
lein compile
lein clean
```
--------------------------------
### Compiling Sass Files Once with lein-sassc (Shell)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/sassc/docs/sassc_instructions.md
This command compiles Sass files a single time using the `lein-sassc` plugin. It's typically used for initial compilation or when manual recompilation is desired after changes.
```Shell
lein sassc once
```
--------------------------------
### Setting Servlet Context Variable in JavaScript
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/expanded/resources/html/base.html
This snippet conditionally declares and initializes a JavaScript variable named 'context'. The variable's value is dynamically injected from the server-side 'servlet-context' variable, but only if the 'servlet' condition is true. This is typically used to provide the application's base path to client-side scripts.
```JavaScript
<% if servlet %> var context = "{{servlet-context}}"; <% endif %>
```
--------------------------------
### Styling Full-Page Layout with CSS
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/expanded/resources/html/error.html
This CSS snippet defines styles for a full-page layout, ensuring the HTML and body elements occupy 100% height and width. It uses `display: table` and `display: table-cell` for fluid container and row alignment, centering content vertically. This is typically used for error pages or single-page applications to ensure consistent sizing and positioning.
```CSS
html { height: 100%; min-height: 100%; min-width: 100%; overflow: hidden; width: 100%; } html body { height: 100%; margin: 0; padding: 0; width: 100%; } html .container-fluid { display: table; height: 100%; padding: 0; width: 100%; } html .row-fluid { display: table-cell; height: 100%; vertical-align: middle; }
```
--------------------------------
### Displaying Dynamic Error Information in HTML Template
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/expanded/resources/html/error.html
This snippet demonstrates how to display dynamic error information within an HTML template. It uses conditional logic (`{% if ... %}`) to render a title and message if they are provided, along with the error status. It also includes a directive to link a CSS file based on a condition, common in templating engines like Jinja2 or Liquid.
```Templating Language
{% style "<% if war %>/<><% else %><% endif %>/assets/bulma/css/bulma.min.css" %}\nError: {{status}}\n{% if title %}\n\n{{title}}\n---------\n\n{% endif %} {% if message %}\n\n#### {{message}}\n\n{% endif %}
```
--------------------------------
### Cleaning Generated Sass Files with lein-sassc (Shell)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/sassc/docs/sassc_instructions.md
This command removes all CSS files that were previously generated by the `lein-sassc` plugin. It's useful for cleaning up the build directory and ensuring a fresh compilation.
```Shell
lein sassc clean
```
--------------------------------
### Conditionally Defining JavaScript Context in Luminus Template
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/core/resources/html/base.html
This Luminus template snippet conditionally defines a JavaScript variable 'context' based on the 'servlet' condition. The variable's value is dynamically inserted from the 'servlet-context' template variable, typically providing the application's root path for client-side scripts.
```Luminus Template
<% if servlet %> var context = "{{servlet-context}}"; <% endif %>
```
--------------------------------
### Auto-Recompiling Sass Files on Change with lein-sassc (Shell)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/sassc/docs/sassc_instructions.md
This command sets up `lein-sassc` to automatically recompile Sass files whenever changes are detected in the source files. This is particularly useful during development for continuous compilation without manual intervention.
```Shell
lein auto sassc once
```
--------------------------------
### Removing lein-sassc Hook from project.clj (Clojure)
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/sassc/docs/sassc_instructions.md
This snippet shows the configuration entry in `project.clj` that registers `lein-sassc` as a Leiningen hook. It needs to be removed when deploying to platforms like Heroku where the SassC binary is not available at compile time, requiring pre-compiled CSS to be committed.
```Clojure
:hooks [leiningen.sassc]
```
--------------------------------
### Linking Stylesheet in Luminus Template
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/core/resources/html/base.html
This Luminus template directive links an external CSS file to the page. It's used to apply styling defined in '/css/screen.css' to the rendered HTML.
```Luminus Template
{% style "/css/screen.css" %}
```
--------------------------------
### Toggling Mobile Navigation with JavaScript
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/expanded/resources/html/base.html
This JavaScript Immediately Invoked Function Expression (IIFE) handles the click event for a 'burger' icon, typically used in mobile navigation. It toggles the 'is-active' class on both the burger icon and the associated navigation element, revealing or hiding the menu. It requires HTML elements with classes 'burger' and an ID matching 'burger.dataset.target'.
```JavaScript
(function() {
var burger = document.querySelector('.burger');
var nav = document.querySelector('#'+burger.dataset.target);
burger.addEventListener('click', function(){
burger.classList.toggle('is-active');
nav.classList.toggle('is-active');
});
})();
```
--------------------------------
### Defining Page Scripts Block in Luminus Template
Source: https://github.com/luminus-framework/luminus-template/blob/master/resources/leiningen/new/luminus/core/resources/html/base.html
This Luminus template directive defines a named content block for 'page-scripts'. Other templates or layouts can extend this block to inject specific JavaScript code or script tags into this section of the page.
```Luminus Template
{% block page-scripts %} {% endblock %}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.