Giter Site home page Giter Site logo

daveeel / hello-react-meteor-livescript Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arunoda/hello-react-meteor

2.0 1.0 0.0 37 KB

Learning Some React with Proper Meteor Integration (Routing, SSR)

JavaScript 4.99% CSS 3.86% LiveScript 91.15%

hello-react-meteor-livescript's Introduction

A fork from the source of: Learning Some React with Proper Meteor Integration (Routing, SSR) https://kadira.io/blog/meteor/meteor-ssr-support-using-flow-router-and-react

Plus:

  • Use Livescript to remove the JSX hell
  • Use _ as helper of React.createElement and makes null optional. It could be used directly in Livescript: _div props, children or _ \div, props, children. Or in Javascript: _div(props,children) or _('div',props,children). Inspired from: redbadger/react-isomorphic#5
  • Now we have the full power of a functional scripting language and jade-like templates truly unified.

We could write .jsx

  getContent() {
    return <div>
      <a href={FlowRouter.path('/')}>Back</a>
      <h3>{this.data.post.title}</h3>
      <p>{this.data.post.content}</p>
    </div>;
  },

as .ls:

  getContent: ->
    _div do # the following is an array of children
      * _a href: FlowRouter.path('/'), \Back
        _h3 this.data.post.title
        _p this.data.post.content

It's a personal choice to use other short variable names like $ or dom_.

The above approach is a time saver that helps faster flow in quick prototyping. However since React promotes component reusability, considering cross-team code readability, such time-saving syntax might not be everyone's cup of tea.

P.S.: Original tag-name functions like div, a could be directly used by importing them all to global namespace by: @ <<< React.DOM as mentioned here: http://red-badger.com/blog/2014/05/27/using-livescript-with-react/ . Just we need to fill in null for elements without props. But having hundreds of global functions like a, br, div etc... might be a bad idea.

hello-react-meteor-livescript's People

Contributors

arunoda avatar daveeel avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.