npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

candor

v0.1.9

Published

A new way to write HTML, elegantly.

Downloads

28

Readme

Candor

A new way to write HTML, elegantly.

Build Status

Example

head
    title = 'Hello World'

body
    div #'app' .'container'
        div .'row'
            div .'col-xs-12 text-center'
                img src'images/sick.png'
                p = 'This is pretty sick!'

Transforms into the following:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Hello World</title>
</head>
<body>
    <div id="app" class="container">
        <div class="row">
            <div class="col-xs-12 text-center">
                <img src="images/sick.png" />
                <p>This is pretty sick!</p>
            </div>
        </div>
    </div>
</body>
</html>

Installation

Laravel Elixir

If you use Laravel like I do, you'll probably want the Elixir plugin, get it here laravel-elixir-candor.

Gulp

If you like using Gulp, get the gulp plugin here gulp-candor

Manually

Otherwise, in your project directory, run the following command

npm install candor --save

then simply call the following where necessary

var candor = require('candor');
var html = candor.parse(...) // Parse the candor syntax here.

Usage

HTML Tags

name #'id' .'classes' key'value' +mutator = 'Inline content'

The only required section above is name.

Tag properties are added as key'value'.

Mutators, which are really just properties without values, such as disabled are denoted as +disabled.

Inline content is optional, but if needed is simply specified as = 'content' at the end of a tag. If this section is present, the opening and closing tags generated will be placed onto a single line instead of separate lines.

Eg:

div #'app' .'app app__dark' @click.stop'toggle()' +disabled = 'Hello!'

the above will produce the following rendered HTML:

<div id="app" class="app app__dark" @click.stop="toggle()" disabled>Hello!</div>

Comments

? This is a comment.

Comments will not be present in the rendered HTML.

Raw Content

script type'text/javascript'
    -- alert('hello world!');

If you require some JavaScript, PHP etc, simply prepend the code with -- and it will be rendered as is. The above would produce:

<script type="text/javascript">
    alert('hello world!');
</script>

HTML content

div
    'This is a paragraph.'

HTML content, aka the content that goes inside of a tag, is simply placed within single quotes. The above example would produce:

<div>
    This is a paragraph.
</div>

Partials

If you don't want candor to automatically add the HTML5 headers to the generated document, simply add !partial to the beginning of the document.

Eg:

!partial

div = 'Some partial content...'

Roadmap

  • [x] Design the syntax.
  • [x] Build a parser/generator.
  • [x] Allow for the generation of partials.
  • [ ] Allow for user defined indent sizes.
  • [ ] Allow for better customization of rendered HTML5.
  • [ ] Support for inline tags.
  • [x] Support for Unicode (Currently limited to ASCII).
  • [x] Create a gulp plugin. gulp-candor
  • [x] Create a Laravel elixir plugin. laravel-elixir-candor