Comments (9)
Hi! Been inactive for a while since I was on holidays :) I see a lot of activity around, very cool!
I strongly support the idea to move the html to a template, will make the code much cleaner. Do you have a particular library in mind? I quick googled jsx but didn't got immediate feedback on how to use it from node.js. For diffy I used Mozilla Nunjucks and I really liked it. It was very similar of template systems I've used before (Django templates, Jinja, etc) and very lightweight too. Can you share your thoughts? :)
Cheers
from diff2html.
Hi @pbu88, I already worked a bit on it in branch react-jsx-html.
In that branch I already have a small html part that works both for the browser and for inclusion in other node plugins.
What I used was a mix of react and jsx. The idea of what I did was to write html, and then use the react html to jsx transpiler. In the end I am requesting the jsx to give me the html strings from the html written before.
With this combination, I can create reusable html components that are parameterized. Check here for more details.
Other resources:
Take a look and see what you think compared to Mozilla Nunjucks
, I will try to look at Mozilla Nunjucks
in the meantime.
from diff2html.
Interesting! Will take a look, thanks!
from diff2html.
Hi! I took a look at JSX and React. I think that that library is too huge and tries to accomplish a lot more than what we might need here, for example, is designed to keep the html and the data in javascript in sync (like other MVC frameworks in js) and a lot more, and using it just to create tiny html templates that don't need to keep sync with a javascript model is rather overkilling.
I think we need to separate/isolate the html, in a way that can be overridden or modified via config, but I think we can accomplish that with something simple. Take a look at #47, I moved them into their own methods with arguments and in my point if view it started to look a lot simpler and isolated.
Changing all our files for jsx and using react might be too much for what we need here.
What do you think? Merry christmas and happy new year btw :)
from diff2html.
Regarding the PR I think it makes sense to separate the components and for that reason I already merged it.
Regarding the JSX + React, the idea is that I really hate to append strings to create the HTML, using the JSX transpiler and the React html generator we can have a better looking HTML without using the complexity of the react framework.
Do you have any other easier alternatives? I already looked into Mozilla Nunjucks
but it is a complete templating language, and in the end we will need to separate the JS from the HTML. Using react we can mix it without making it too weird to write.
from diff2html.
Yeah, concatenating the strings is a real pain. I'm not sure on how to follow on this though. When I saw the branch this is being worked on I found it a bit intimidating to start dealing with .jsx
files but that is just me, maybe is not a big issue.
Another option (to avoid concatenating) might be move the html string to a external file. Either with .html extension (more like a template approach) or to a .jsx extension .this way normal javascript files will be .js and the .jsx will be very clear that they are a template somehow. I'm just thinking out loud :)
from diff2html.
@pbu88 I think the idea of the file templates could be interesting, it is always good to separate ui from, the code. My only concern is for it to not get more complex.
Can we do it with Mozilla Nunjucks
?
We would need at least to have some templates and be able to include them inside each other (something like imports)
How is the integration of Mozilla Nunjucks
with node?
Do you know any better alternative to do some experiences?
from diff2html.
The integration is very straight forward. I'll come up with a prototype and we can decide if we like it or not. I personally like the idea, at the end of the day what we have are embedded templates in code, so if we move it to its own template file it can add simplicity and a way to override them. I'll come up with something and we can discuss further.
from diff2html.
Hogan.js was choosen for the HTML templating language.
from diff2html.
Related Issues (20)
- side-by-side diff is broken in Firefox HOT 2
- Output of diff not preserving escaped HTML characters HOT 3
- Can't run diff2html-cli on linux docker container HOT 2
- Make templates more flexible HOT 4
- How to remove the serial number of blank lines HOT 3
- Blank context lines are ignored by diff parser HOT 1
- Vertical align mismatch between inserted/deleted text and matching
- Code breaking when there is no change in a line HOT 3
- Is it possible to generate single html report for multiple git repos? HOT 1
- Unknown argument: diff.txt HOT 1
- 12341
- Suggest new option to Diff2Html library HOT 1
- If the diffString contains special symbols, the page will report an error HOT 1
- Diff2html fails with Error: Cannot find module 'tslib'
- Slim version doesn't fallback to 'plaintext' on unsupported file type HOT 4
- File list links are not working in Angular integration for diff2html-ui HOT 2
- the `multiline comment` syntax can not highlight correctly HOT 1
- CSS not working inside shadow DOM
- Feature request: option to only show first n files HOT 3
- when execute git diff --word-diff-regex=. ,diff2html is not work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diff2html.