Registry / web-framework / flave
library1.5.3jsnpmunverified

Flave (Full Logic Access View Engine) is a Razor-like view transpiler for JavaScript that compiles template files into plain JavaScript functions returning strings. Version 1.5.3 is the current stable release, with irregular cadence. Unlike many templating engines that restrict logic, Flave gives full access to JavaScript via code blocks and expressions. It is isomorphic (no DOM required), supports custom configuration for quoting, whitespace, and exports, and integrates with editors like VSCode and Atom through community extensions.

npm install flave
INSTALL
IMPORT
SIG · FLAVE
F
flave
web-frameworkjavascriptv1.5.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

flave
const flave = require('flave');
const { flave } = require('flave');
Package exports a single function via default export in CommonJS. There is no named export.
transpile
flave.transpile(flavestring, config);
flave(flavestring, config);
The function is accessed as a method on the imported module. It is not the default export itself.
type imports
import flave from 'flave';
import * as flave from 'flave';
For ESM usage, use default import. Type definitions are not bundled; consider adding @types/flave if available.

Shows how to load a .flave file, transpile it using configuration options, and output the resulting JavaScript code.

const flave = require('flave'); const fs = require('fs'); const config = { quote: '"', stripcomments: true, output: '$O', trim: true, newlines: true, format: false, export: true }; fs.readFile('template.flave', 'utf8', (err, data) => { if (err) throw err; const jsCode = flave.transpile(data, config); console.log(jsCode); });
Debug
Known issues
gotchaThe transpiled output uses a variable named `$O` by default for HTML string accumulation. If your view uses '$O' as a data property, it will conflict.
fix
Set the `output` config option to a unique variable name, e.g., `output: '__html'`.
affects: >=0.0.0
gotchaThe `export` configuration option (default true) auto-adds `module.exports`. If you are transpiling for the browser, set `export: false` to avoid Node.js specific code.
fix
Set `export: false` in config when targeting browser environments.
affects: >=0.0.0
gotchaThe `format` option defaults to `true`, but its indentation may not work correctly with complex code blocks. Disable it if the output looks malformed.
fix
Set `format: false` in config to get unformatted but consistent JavaScript.
affects: >=0.0.0
gotchaComments in `view` and `function` blocks are stripped by default (stripcomments: true). Retaining them may affect output.
fix
Set `stripcomments: false` to preserve comments.
affects: >=0.0.0
Errors
Common errors & fixes
ReferenceError: flave is not defined
The package was not imported or the require path is incorrect.
fix
Use `const flave = require('flave');` with correct path.
TypeError: flave.transpile is not a function
The imported object does not have a 'transpile' method (wrong import pattern).
fix
Ensure you import the module correctly: `const flave = require('flave');` then call `flave.transpile()`.
SyntaxError: Unexpected token 'class'
The .flave file uses the `class` keyword incorrectly or has a syntax error that resembles JavaScript classes.
fix
Wrap your view/function definitions in a class if you want namespacing, but ensure the syntax follows Flave rules: `class name { view viewname { } }`.
Upgrade
Version history
1.5.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
flave — npm install flave · libregistry