{"id":25594,"library":"flave","title":"Flave","description":"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.","status":"active","version":"1.5.3","language":"javascript","source_language":"en","source_url":"https://github.com/varubi/flave","tags":["javascript","Razor","view","Transpiler","Template"],"install":[{"cmd":"npm install flave","lang":"bash","label":"npm"},{"cmd":"yarn add flave","lang":"bash","label":"yarn"},{"cmd":"pnpm add flave","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package exports a single function via default export in CommonJS. There is no named export.","wrong":"const { flave } = require('flave');","symbol":"flave","correct":"const flave = require('flave');"},{"note":"The function is accessed as a method on the imported module. It is not the default export itself.","wrong":"flave(flavestring, config);","symbol":"transpile","correct":"flave.transpile(flavestring, config);"},{"note":"For ESM usage, use default import. Type definitions are not bundled; consider adding @types/flave if available.","wrong":"import * as flave from 'flave';","symbol":"type imports","correct":"import flave from 'flave';"}],"quickstart":{"code":"const flave = require('flave');\nconst fs = require('fs');\n\nconst config = {\n  quote: '\"',\n  stripcomments: true,\n  output: '$O',\n  trim: true,\n  newlines: true,\n  format: false,\n  export: true\n};\n\nfs.readFile('template.flave', 'utf8', (err, data) => {\n  if (err) throw err;\n  const jsCode = flave.transpile(data, config);\n  console.log(jsCode);\n});","lang":"javascript","description":"Shows how to load a .flave file, transpile it using configuration options, and output the resulting JavaScript code."},"warnings":[{"fix":"Set the `output` config option to a unique variable name, e.g., `output: '__html'`.","message":"The 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.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set `export: false` in config when targeting browser environments.","message":"The `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.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set `format: false` in config to get unformatted but consistent JavaScript.","message":"The `format` option defaults to `true`, but its indentation may not work correctly with complex code blocks. Disable it if the output looks malformed.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set `stripcomments: false` to preserve comments.","message":"Comments in `view` and `function` blocks are stripped by default (stripcomments: true). Retaining them may affect output.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `const flave = require('flave');` with correct path.","cause":"The package was not imported or the require path is incorrect.","error":"ReferenceError: flave is not defined"},{"fix":"Ensure you import the module correctly: `const flave = require('flave');` then call `flave.transpile()`.","cause":"The imported object does not have a 'transpile' method (wrong import pattern).","error":"TypeError: flave.transpile is not a function"},{"fix":"Wrap your view/function definitions in a class if you want namespacing, but ensure the syntax follows Flave rules: `class name { view viewname { } }`.","cause":"The .flave file uses the `class` keyword incorrectly or has a syntax error that resembles JavaScript classes.","error":"SyntaxError: Unexpected token 'class'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}