punchtheceiling•

It would've probably been better to specify that this was a string templating library. Also maybe it would be a good idea to compare using your library to how you would have to do it in plain C++.

11
ginstromOP•

Thanks, I've edited the blog post a little to reflect your advice. (Edit: spelling)

2
[deleted]•
7
ginstromOP•

Yes, I found it back when I was looking for a templating engine. I wrote my own because at the time, CTemplate didn't support Windows (it might now). I also named it a "template language" because that's what CTemplate calls it, although some people have commented that it's not a good name.

5
[deleted]•

Actually, I was expecting something template metaprogramming -related when I clicked the link. But I was also expecting that when I first saw the google's library.

The term would make perfect sense for other languages though, eg. Perl and PHP...

7
ErstwhileRockstar•

I vaguely remember that C++ templates looked different the last time I looked at them.

3
axilmar•

and generating the HTML right in the C++ quickly got very hairy

I'd make an API that would allow me to do the following:

    h3 << "Locations" << -h3 <<
    ul <<
        for_each(places, li << _1 << -li) <<
    -ul;
    
3
MachinShin2006•

ooohh.. i kinda like that.

1
ginstromOP•

Nice, but that doesn't change the problem that you need to recompile every time you change your documents.

In general, I like the web frameworks' approach of separating business logic from presentation.

1
axilmar•

Nice, but that doesn't change the problem that you need to recompile every time you change your documents.

Why is recompiling a problem?

1
ginstromOP•

Because it makes it take a lot more time to edit documents.

Also, what if:

  • Your users want to edit the document layout themselves?
  • You want to generate documents in multiple languages?
  • You want to edit the documents while the program is running?

These are all issues that I've had, and they helped convince me to go the template route.

1
axilmar•

Because it makes it take a lot more time to edit documents.

I suppose you meant that compiling takes a lot more time than editing documents. Well, how is that true? if your application is coded correctly, doing a simple change in the documents takes roughly the same time as hitting F5 in Visual Studio and compiling the app.

Your users want to edit the document layout themselves?

Why would the users of your app ever need to do that?

You want to generate documents in multiple languages?

You provide a translation function.

You want to edit the documents while the program is running?

As soon as you make the new version, you redirect new requests to the new executable. The previous one is left running until no more requests to it are made.

1
last_useful_man•

-1 If everyone dumped their libraries into r/programming it would be very annoying.

-12
ehnus•

Heaven forbid people post programming topics instead of imgur links!

10