Skip to content

krokis/layla-plugin-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Layla Env plugin

Read and write environment variables from Layla code.

Installation

Install as a dependency of your project with NPM:

npm install layla-plugin-env --save # or --save-dev

Usage

Require the plugin in your stylesheet. An Env object will be injected wherever you use the plugin. Use the :: operator on it to read and write environment variables:

// Use the plugin
use 'env'

// Read the `DEBUG` environment variable
$debug = Env::DEBUG

// Write (export) the `DEBUG` environment variable
Env::DEBUG = 0

All values are returned as strings and implicitly converted to strings when they're set. If you try to read an undefined variable, you'll get null. Set a variable to null to delete it.

html {
  use 'env'

  Env::DEBUG = true
  debug: Env::DEBUG
  undefined: Env::THIS_ONE_SHOULD_NOT_EXIST
  Env::AN_EMPTY_STRING = ""
  empty: Env::AN_EMPTY_STRING
}
html {
  debug: "true";
  undefined: null;
  empty: '';
}

License

BSD-3-Clause

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published