13
u/jasonthe Jun 28 '20
This is super dumb, I love it :P
I was able to get the whole thing to run at compile-time!
2
u/csb06 Jun 28 '20
Wow that looks really cool! C++ scares me sometimes with what it lets you do. Glad you found it interesting :)
2
u/kritzikratzi Jun 28 '20
yea, and i'm actually wondering about performance... the result looks a bit complicated, so many moves going on compared to what a
cout<<"<html><head>...</html>"produces.3
u/jasonthe Jun 28 '20 edited Jun 29 '20
If you tweak it to not use
new, and instead just use local arrays, clang can understand it. And clang optimizes all those moves away :)I don't feel like rewriting his whole library, but here's a sample that shows what I mean: https://godbolt.org/z/f26WrH
2
90
u/nrith Jun 27 '20
From the README:
Should I use it
Probably not.
39
u/HeySeussCristo Jun 27 '20
Enjoyed this bit too:
h1<"The horror!">, p<"Someone has probably done this before, but I can see why it didn't catch on.">,14
u/UnDosTresPescao Jun 27 '20
I was reading it thinking "This is the dumbest way to write html I've ever seen". I was happy to see the author didn't take themselves too seriously
14
12
u/RomanRiesen Jun 28 '20
The c++ syntax is actually better since we don't have to repeat the tags, reducing redundancy.
We should probably have a js library to render the c++ templates syntax directly, as they will certainly overtake html in the next decade!
2
u/csp256 Jun 28 '20
Roommate just called from the other room "what's so funny?".
2
0
Jun 28 '20
[deleted]
2
u/csp256 Jun 28 '20
She assumed I had found another cute animal gif, but I just told her "this one's a programming joke".
2
1
u/onlyari Jun 29 '20
Can you use loops and conditions with this? It could be valuable to generate large html code using this template in a loop or based on some input parameters.
1
1
0
u/Mashpoe Jun 27 '20
That's pretty cool! I've thought about making some kind of HTML template tool before, but I wasn't sure how it would work or what its use would be. This is useful because it's much better than trying to directly print out HTML code.
0
55
u/looncraz Jun 27 '20
This, frankly, looks easier than writing HTML directly... Plus free error checking... Too bad template error messages are horrendously ugly.