Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fig-compiler

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fig-compiler

fig.js component compiler

  • 0.2.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

fig-compiler stability

fig.js component compiler

npm travis

usage

api

obj = compiler(input[, opts])

Where input is a string a of fig component. Available options for the opts object are as follows:

  • opts.filePath - required if you want to use pug's relative includes/extends inside of the component
  • opts.defaultName - name set for the component, if the label is missing on the component
  • opts.debug - if set to true passes debug and compileDebug to pug, tldr: if false output is smaller, at the cost of some pretty error messages

Returns an obj which has a few properties:

  • obj.template - a function compiled by pug that takes a locals object and spits out HTML when asked to
  • obj.style - just a string containing the contents of the style tag inside the component
  • obj.script - string of code which just so happens to be ran through babel with the es-2015 preset for your dearest convenience.
  • obj.name - name of the component, taken from the label tag, or opts.defaultName if that doesn't exist. Otherwise undefined

connect middleware

For development pleasure, this module includes a simple connect middleware function, compatible with express. Used akin to express.static middleware, point it to the directory you store your fig components in, the middleware should compile the component on the fly (without caching) and serve it to the client.

:warning: Not meant to be used in production.

example

// server.js
const express = require('express')
const fig = require('fig-compiler/connect')

const app = express()
app.use(fig('components'))

app.listen(3000)

// client.js
const app = fig()
app.use('main-view.fig') // pulls from localhost:3000/main-view.fig
app._components.get('main-view') // should be the compiled component

install

npm install fig-compiler --save

license

MIT

  • fig.js - experimental front-end ui framework
  • figify - fig.js browserify transform
  • fig-web - fig.js website

FAQs

Package last updated on 19 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc