rtfpessoa / diff2html

Pretty diff to html javascript library (diff2html)
https://diff2html.xyz
MIT License
2.8k stars 273 forks source link

Hogan.js is unmaintained #435

Open SydneyUni-Jim opened 2 years ago

SydneyUni-Jim commented 2 years ago

https://github.com/twitter/hogan.js/issues/272 (2 May 2021)

It's been ~8 years since I seriously worked on this project […] After this work is done, I'll add a note to the README that makes it clear the project is not adding new features, and is in maintenance mode. Serious bugs, such as security issues, will be addressed. New features and performance work can be done in a fork.

The last time a pull request was closed was 8 Jun 2019. The dependencies in hogan.js are becoming deprecated (https://github.com/twitter/hogan.js/pull/270) and security vulnerabilities are being exposed (https://github.com/twitter/hogan.js/pull/276).

rtfpessoa commented 2 years ago

👋 I understand that it is not being maintained anymore but it has been very stable and fits very well the use case.

Do you have any alternatives we can use?

Also AFAIK we have no active vulns https://github.com/rtfpessoa/diff2html/security/dependabot

jgonggrijp commented 1 year ago

@rtfpessoa I'm currently developing Wontache, which can be thought of as a successor of hogan.js (although the code bases are not actually related). I haven't reached the 1.0.0 release yet, but it's fully tested, passes all the official Mustache specs (including the newest) and is even more accurate at whitespace handling than hogan.js. In my own testing, it also seems to be at least as fast as hogan.js, but you might want to try that for yourself on a feature branch.

The API is slightly different, the compiler returns a function that you can then call with the data:

import mustache from 'wontache';

const templateText = 'Interpolate {{variable}} here.';
const compiledTemplate = mustache(templateText);
const renderedOutput = compiledTemplate({variable: 'foo'});
// 'Interpolate foo here.'

While I'm not proud enough yet to draw a lot of attention to Wontache, I would definitely welcome diff2html as a first serious outside user.

rtfpessoa commented 1 year ago

👋 @jgonggrijp did a quick test and seems like it works.

For me the most important things missing are:

Do you think these are things you will be interested in doing?

jgonggrijp commented 1 year ago

@rtfpessoa Yes, the first and the last point are planned. Please clarify the middle point!

jgonggrijp commented 1 year ago

Potentially relevant issue tickets, in case you want to track them:

rtfpessoa commented 1 year ago

Do you have any ideas for timelines here?

jgonggrijp commented 1 year ago

As far as order is concerned, the development board conveys best how I prioritize the issues. I want to finish the evaluation release milestone this year if I can help it, and the official launch milestone as soon as possible after that.

As far as calendar time is concerned, unfortunately I can spend at most two days a week on my open source libraries and I have to divide my attention between Wontache, Backbone and Underscore (I took over maintainance of the latter two from the original author). I get to it whenever I get to it, so I cannot promise any particular date.

If you are seriously considering to use Wontache, please let me know which issues are the most important to you. The priorities are somewhat flexible; in fact, I already moved the WebPack plugin up because it seemed relevant to diff2html and I expect it to be quick to implement.

(Also, please consider donating to my Patreon and recruiting other people to do so. Given substantial sponsorship, I might be able to increase my time investment in open source libraries such as Wontache.)

By the way, you mentioned this earlier:

  • Seems like codegen is not optimal since some functions have unused parameters, for example

Please clarify.

t1m0thyj commented 1 year ago

@rtfpessoa Would it be possible to publish the 3.0.0-beta.1 tag in the "use-wontache" branch to NPM, since all tests are passing? My team would like to use diff2html but we are not allowed to use deprecated/unmaintained packages. Thanks! 🙏

rtfpessoa commented 1 year ago

@t1m0thyj I just released version 3.4.20-usewontache.1.60e7a2e with the initial wontache implementation.

t1m0thyj commented 1 year ago

Thanks for the quick response! So far the beta version seems to be working well for us.

In case anyone else wants to try it out in a TypeScript project, here's what I did to work around wontache not having type definitions yet. I created a file __types__/wontache.d.ts:

// Remove this file once wontache adds type definitions
declare module 'wontache' {
    type CompiledTemplate = any;
    type Partials = any;
}

and added this to tsconfig.json:

  "files": [
    "./__types__/wontache.d.ts"
  ]
rtfpessoa commented 1 year ago

I created these more details typings https://github.com/rtfpessoa/diff2html/blob/use-wontache/typings/wontache/wontache.d.ts

jgonggrijp commented 1 year ago

@rtfpessoa I just released Wontache version 0.2.0, which has a couple of new features and bugfixes, as well as a breaking change in the way precompiled templates are represented.

Along with this new version, I released the new packages rollup-plugin-wontache and wontache-loader. You can use the latter for bundling your templates with your code directly with webpack, so you (hopefully) don't need the custom logic in scripts/hulk.ts anymore. I also published a new playground where you can try all wontache features from your browser (including partials and parents).

Update: added more links for convenience.