digitalmars.D.announce - d_to_html.d
- WebFreak001 (52/52) Aug 05 2017 Hi, I made a D to HTML generator which is basically diet, but
- David Gileadi (5/7) Aug 05 2017 [snip]
- crimaniak (3/10) Aug 06 2017 The best thing for Olympic programming, horrible hack for
- Meta (5/57) Aug 05 2017 Just because you *can* do something, it doesn't mean you
- Jacob Carlborg (6/57) Aug 06 2017 Wow, that's pretty cool :). One downside I see is that all tags are
- Biotronic (16/19) Aug 08 2017 That's easily amendable:
- solidstate1991 (2/5) Aug 06 2017 Finally! I can have a footing in frontend development!
- TheGag96 (4/5) Aug 06 2017 Man, this is absolutely nuts. Overriding opBinary to catch
- jmh530 (3/6) Aug 07 2017 I don't think I had noticed either of those things when I skimmed
- =?iso-8859-1?Q?Robert_M._M=FCnch?= (8/14) Aug 09 2017 That's pretty cool and comes very close to a domain specific language.
Hi, I made a D to HTML generator which is basically diet, but fully using the D compiler as generator and not some complicated parser, etc. Here an example what you pass in: string page = html( head( title("wtf is this"), style( html( font-family = "Roboto", background = 0xEFEFEF ), div.content( max-width = 800.px, margin = auto_, margin-top = 32.px, box-shadow = "0 2px 5px rgba(0, 0, 0, 0.3)", background = white, padding = 32.px ), div.footer( text-"align" = center ) ) ), body( div.content( h1("The most crappy HTML generator ever"), div.teaser( p("Super fast") ), hr, p("Reasons why you should use d_to_html:"), ul( li("TODO: no reason yet") * 5 ) ), div.footer( p(raw!"© 2017 webfreak.org") ) ) ).toString; Which generates: https://i.webfreak.org/fStzn0.html Full source: https://gist.github.com/WebFreak001/6a1916779e48898c7ababc47a3113829 Though some things (like min and max for example) won't work correctly, so you need to manually write `attr!"min" = 4` if you wanted to add that to an input element. btw this is just a joke project, it's totally abusing operator overloading just to show what is possible with it. The idea came up in Wild's discord server, you can join us too, we have a programming and a dplug channel: https://discordapp.com/invite/bMZk9Q4
Aug 05 2017
On 8/5/17 12:07 PM, WebFreak001 wrote:Hi, I made a D to HTML generator which is basically diet, but fully using the D compiler as generator and not some complicated parser, etc.[snip] That is amazing! I can't decide whether it's the best thing I've ever seen or a horrible hack, but it's a great showcase for what you can do with D.
Aug 05 2017
On Sunday, 6 August 2017 at 00:22:32 UTC, David Gileadi wrote:On 8/5/17 12:07 PM, WebFreak001 wrote:The best thing for Olympic programming, horrible hack for production code. :)Hi, I made a D to HTML generator which is basically diet, but fully using the D compiler as generator and not some complicated parser, etc.[snip] That is amazing! I can't decide whether it's the best thing I've ever seen or a horrible hack,
Aug 06 2017
On Saturday, 5 August 2017 at 19:07:50 UTC, WebFreak001 wrote:Hi, I made a D to HTML generator which is basically diet, but fully using the D compiler as generator and not some complicated parser, etc. Here an example what you pass in: string page = html( head( title("wtf is this"), style( html( font-family = "Roboto", background = 0xEFEFEF ), div.content( max-width = 800.px, margin = auto_, margin-top = 32.px, box-shadow = "0 2px 5px rgba(0, 0, 0, 0.3)", background = white, padding = 32.px ), div.footer( text-"align" = center ) ) ), body( div.content( h1("The most crappy HTML generator ever"), div.teaser( p("Super fast") ), hr, p("Reasons why you should use d_to_html:"), ul( li("TODO: no reason yet") * 5 ) ), div.footer( p(raw!"© 2017 webfreak.org") ) ) ).toString; Which generates: https://i.webfreak.org/fStzn0.html Full source: https://gist.github.com/WebFreak001/6a1916779e48898c7ababc47a3113829 Though some things (like min and max for example) won't work correctly, so you need to manually write `attr!"min" = 4` if you wanted to add that to an input element. btw this is just a joke project, it's totally abusing operator overloading just to show what is possible with it. The idea came up in Wild's discord server, you can join us too, we have a programming and a dplug channel: https://discordapp.com/invite/bMZk9Q4Just because you *can* do something, it doesn't mean you *should*. ;-) Very creative, I don't think reading source code has ever made me chuckle before.
Aug 05 2017
On 2017-08-05 21:07, WebFreak001 wrote:Hi, I made a D to HTML generator which is basically diet, but fully using the D compiler as generator and not some complicated parser, etc. Here an example what you pass in: string page = html( head( title("wtf is this"), style( html( font-family = "Roboto", background = 0xEFEFEF ), div.content( max-width = 800.px, margin = auto_, margin-top = 32.px, box-shadow = "0 2px 5px rgba(0, 0, 0, 0.3)", background = white, padding = 32.px ), div.footer( text-"align" = center ) ) ), body( div.content( h1("The most crappy HTML generator ever"), div.teaser( p("Super fast") ), hr, p("Reasons why you should use d_to_html:"), ul( li("TODO: no reason yet") * 5 ) ), div.footer( p(raw!"© 2017 webfreak.org") ) ) ).toString; Which generates: https://i.webfreak.org/fStzn0.html Full source: https://gist.github.com/WebFreak001/6a1916779e48898c7ababc47a3113829 Though some things (like min and max for example) won't work correctly, so you need to manually write `attr!"min" = 4` if you wanted to add that to an input element. btw this is just a joke project, it's totally abusing operator overloading just to show what is possible with it. The idea came up in Wild's discord server, you can join us too, we have a programming and a dplug channel: https://discordapp.com/invite/bMZk9Q4Wow, that's pretty cool :). One downside I see is that all tags are currently hard coded. This won't work for XML or if using new/custom tags that the library doesn't know about yet. -- /Jacob Carlborg
Aug 06 2017
On Sunday, 6 August 2017 at 15:18:29 UTC, Jacob Carlborg wrote: [snip]Wow, that's pretty cool :). One downside I see is that all tags are currently hard coded. This won't work for XML or if using new/custom tags that the library doesn't know about yet.That's easily amendable: struct ElementBuilder { auto opDispatch(string name, Args...)(Args args) const { return Element(name)(args); } } enum xml = ElementBuilder(); unittest { enum a = xml.foo(xml.bar("baz"), xml.qux(123)); assert(a.toString == "<foo><bar>baz</bar><qux>123</qux></foo>"); } -- Biotronic
Aug 08 2017
On Saturday, 5 August 2017 at 19:07:50 UTC, WebFreak001 wrote:Hi, I made a D to HTML generator which is basically diet, but fully using the D compiler as generator and not some complicated parser, etc.Finally! I can have a footing in frontend development!
Aug 06 2017
On Saturday, 5 August 2017 at 19:07:50 UTC, WebFreak001 wrote:snipMan, this is absolutely nuts. Overriding opBinary to catch hyphens, aliasing opAssign to opCall... Just evil, haha! Amazing job!
Aug 06 2017
On Monday, 7 August 2017 at 02:32:56 UTC, TheGag96 wrote:Man, this is absolutely nuts. Overriding opBinary to catch hyphens, aliasing opAssign to opCall... Just evil, haha! Amazing job!I don't think I had noticed either of those things when I skimmed it the first time. Thanks for highlighting.
Aug 07 2017
On 2017-08-05 19:07:50 +0000, WebFreak001 said:Hi, I made a D to HTML generator which is basically diet, but fully using the D compiler as generator and not some complicated parser, etc. Here an example what you pass in: string page = html( ...That's pretty cool and comes very close to a domain specific language. This would make it possible to get declarative GUI layout etc. in with a much nicer syntax. Cool idea. -- Robert M. Münch http://www.saphirion.com smarter | better | faster
Aug 09 2017