Coder Social home page Coder Social logo

vasilii-kovalev / hydrate-text Goto Github PK

View Code? Open in Web Editor NEW
47.0 2.0 1.0 1013 KB

A small, dependency-free and strongly typed template engine.

License: MIT License

TypeScript 100.00%
javascript typescript zero-dependency template string tree-shakable template-engine

hydrate-text's People

Contributors

vasilii-kovalev 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

Watchers

 avatar  avatar

Forkers

omgimalexis

hydrate-text's Issues

README images aren't loading

The last two images show this for me. Going to the img src from the README.md I get "badgen error" or the whole page just shows a 500.

Screen Shot 2021-07-04 at 9 01 36 am

Screen Shot 2021-07-04 at 8 58 39 am

Unexpected token 'export'

When using ts-jest to transform files in Jest tests, the following error occurs:

export { configureHydrateText, hydrateText };
^^^^^^

SyntaxError: Unexpected token 'export'

issue when the testrunner is jest

Hello, I use your lib and I have an issue when I test it with jest:
I have this error :
Cannot use exports statement outside a module

on the last line of your dist/index.js :

exports = { configureHydrateText, hydrateText };

I can correct it if I replace it by:
module.exports = { configureHydrateText, hydrateText };

I'm not sure if the issue is in my Jest config or in your build. I don't have the issue when I launch my app, only during the jest test.

Improve type checking

generatePath function in React Router library supports variable names check, comparing ones from the route string and ones from the variables object.
Types: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router/index.d.ts#L146-L166

It would be great to implement similar type checking in this library.

I tried to do that myself and found, that the approach above works good in case of fixed prefix and suffix values. Otherwise, it is hard to handle edge cases like these:

  • prefix and suffix are empty strings (passed explicitly or passed interpolation options object is empty)

  • Either preffix or suffix is passed (the other becomes an empty string by default, see docs or implementation)

  • prefix and/or suffix are set in configureHydrateText and then overridden in the result function:

    const routeWithCustomInterpolationOptions = "/users/(userId)";
    
    const hydrateRoute = configureHydrateText({ prefix: ":" });
    
    // '/users/3'
    console.log(
      hydrateRoute(
        routeWithCustomInterpolationOptions,
        { userId: 3 },
        {
          prefix: "(",
          suffix: ")",
        },
      ),
    );

Definition of done:

  • Functionality haven't suffered
  • Type checking has improved
  • Linters checks and tests are passing
  • Code coverage is 100%

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.