vasilii-kovalev / hydrate-text Goto Github PK
View Code? Open in Web Editor NEWA small, dependency-free and strongly typed template engine.
License: MIT License
A small, dependency-free and strongly typed template engine.
License: MIT License
The error occurs in the following situations:
// Works perfectly until `{8}` part
hydrateText("{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", {});
// Works perfectly until `9` part
hydrateText("123456789", {}, { prefix: "", suffix: "" });
Related to recursive variables retrieving.
TypeScript issue: microsoft/TypeScript/issues/37613
When using ts-jest
to transform files in Jest tests, the following error occurs:
export { configureHydrateText, hydrateText };
^^^^^^
SyntaxError: Unexpected token 'export'
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.
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:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.