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

lsx-pug

v0.1.57

Published

React plugin for LiveScript

Downloads

14

Readme

lsx-pug - LiveScript Extension

Logo This is Pug/Jade like syntax library for React DOM written on LiveScript

Please support this project (Goal $ 6k)

Wallet

  1. BTC 19Uf4EjwXb2j2FvNvmgY3u7NtM7BYLmrR7
  2. ETH 0x8d23C40C1703b99D0295b3277E4164cE3DAaF7b6
  3. LTC LZFqabuJnk7VavgyTyKe8S9qqGVodbDkRe

Example

{ render } = require \react-dom
{ create, div, a, p } = require \lsx-pug

main = create do
    render : ->
        div do
          a(href: \http://google.com 
            target: \blank) \hello
          p \world

window.onload = ->
    \app |> document.create-element |> document.body.append-child
    render do
        main ""
        \app |> document.query-selector

Installation

Have Node.js installed.

npm i lsx-pug

Usage

1 Import plugin 'lsx-pug'.

{ create, div, a, p } = require \lsx-pug

2 Create class and bind. (example:Main)

main = create do
    render : ->
        div do
            p \hello
            a(href: \http://google.com ) \world

3 Custom Element. (example:Main)

{ create, div, a, p, button } = require \lsx-pug

CustomElement = (on-click: on-click)->
    button(on-click: on-click)

main = create do
    render : ->
        div do
            CustomElement
            a(href: \http://google.com ) \world

4 Render.

{ render } = require \react-dom
render do
    main ""
    \app |> document.query-selector



More Examples

Object Oriented Programming

{ create, Component, div, a, p } = require \lsx-pug

main = create class Main extends Component
    render : ->
        div do
            a \hello
            p \world

Component



div \hello

# <div>hello</div>

Null Contents Component


div ""

# <div />

Nested Component

div do 
    p ""
    p \hello

# <div>
#     <p />
#     <p>hello</p>
# </div>

Set Properties and Style, etc..

div(test-prop : \test ,
    on-click : @test-func ,
    style : {height : 200  width : 200} ) \hello

# <div test-prop = "test"
#      onClick = {this.testFunc}
#      style = {
#          height:200
#          width:200
#      }>
#     hello
# <div>

Use Component and Set Prop-Types

{ create, type, div} = require \lsx-pug

test-component = create do

    prop-types =
        test-class : type.string

    get-default-props = ->
        test-class : \default

    render : ->
        div(class-name: @props.test-class) @props.children

main = create do

    render: ->
        div do
          test-component(test-class: \test ) \hello

Use If Condition


main = create do
    render : ->
        div(title: \title ) do 
            div [div 1, div 2]
            div do
              if 5 is 5  
                 div "conditional div"
              else 
                 div "never happended"
              div "next div"

Use Loops


main = create do

    render: ->
        div do
          for i in [1 to 5]
            div i

Limitations


#This syntax is not supported
 
div() 

#

div

#At least You need to add empty string 

div() "" 

#or 

div ""

#
#Perphaps, in next version, we are going to adjust React validations rules in order to make possible to write 
#

div 

div()