Giter Site home page Giter Site logo

danakt / handlebars-to-jsx Goto Github PK

View Code? Open in Web Editor NEW
57.0 57.0 15.0 587 KB

Converts Handlebars template to React component

License: MIT License

JavaScript 2.60% TypeScript 97.40%
converter converting-handlebars-template handlebars handlebars-template handlebars-to-jsx handlebars-to-react jsx react

handlebars-to-jsx's People

Contributors

andrewleedham avatar blikblum avatar danakt avatar dependabot[bot] avatar rrmdn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

handlebars-to-jsx's Issues

[RFC] Switch @glimmer/syntax with handlebars

After having a conversation with some of the @glimmer/syntax maintainers (glimmerjs/glimmer-vm#948), it seems they do not support partials in any form, and the module is specific to Ember's handlebars flavour. Therefore in order to support #3, and to move away from the Ember specific stuff, I think it would make sense to convert this module to use https://github.com/wycats/handlebars.js which provides a .parse function to generate an AST. @danakt is this something you considered when writing the module, and do you have any reservations?

Reserved words

Need to escape reserved javascript words in handlebars expressions

Support the `unless` block helper

Currently {{#if}} is handled but not {{#unless}}

Example tests (there are formatting options for sure - I'm not super opinionated about that):

    test('should convert condition unless-then ', () => {
      expect(compile('<div>{{#unless variable}}<div/>{{/unless}}</div>')).toBe(
        recompile('props => <div>{!Boolean(props.variable) && <div />}</div>;')
      )
    })

    test('should convert condition unless-then-else ', () => {
      expect(compile('<div>{{#unless variable}}<div/>{{else}}<span/>{{/unless}}</div>')).toBe(
        recompile('props => <div>{!Boolean(props.variable) ? <div /> : <span />}</div>;')
      )
    })

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.