dafky2000 / simplectemplate

Simple C Template library to expand placeholders in a template string, simple alternative to mustache.github.io that doesn't require JSON as data input.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create main.c binary to parse from consumed template file and template variables

dafky2000 opened this issue · comments

So simplectemplate can easily be used as a library OR a program. @andy5995 has already done all the hard work and is willing to contribute his code.

https://github.com/andy5995/simplectemplate/blob/simplecgen/examples/website/src/simplecgen.c

I wasn't sure what you wanted done here. Could you add some specifics?

I simply want to replace my simplectemplate main.c with your main.c. I really don't want any of that autogen stuff though... Unless there is a compelling argument I would simply like to use the current Makefile with minimal changes. All that extra automake stuff seems extremely bloated but I am no expert with compiling and not sure what benefit it provides.

It's more for allowing for expansion of the program. I think the configure script

One of the benefits it provides right now is the ability to pass options when compiling. I don't see most end-users would have to change anything. Being able to pass options to ./configure is mostly the benefit. It's easy to set the target directories for an install.

For one example, I could hard-code a defined constant, such as SYSCONFDIR into simplecgen. And set up the Makefile to use it (I don't think I did that yet).

So using ./configure --sysconfdir=... would add SYSCONFDIR=... to config.h, which could then be included in simplecgen.

Then I can use just SYSCONFDIR in simplecgen to point to the config file.

This is how the config.h looks like now:

/* Name of package */
#define PACKAGE "simplecgen"

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "andy400-dev@yahoo.com"

/* Define to the full name of this package. */
#define PACKAGE_NAME "simplecgen"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "simplecgen 0.1.02"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "simplecgen"

/* Define to the home page for this package. */
#define PACKAGE_URL ""

/* Define to the version of this package. */
#define PACKAGE_VERSION "0.1.02"

/* Version number of package */
#define VERSION "0.1.02"

So any of those definitions could be used in the source code. There are other ways to do it, but this is one way that I'm familiar with.

And tbh, I'm sure there are many benefits I don't understand yet. On larger programs with more dependencies, the configure script can do tests to look for libraries depending on which system you're on.

But I agree that it's not essential to the program right now, and you could get by easily without it. Whatever you decide for your repo is fine with me.

Hi Dan. I think I spaced this. Could you tell me what you'd like done specifically with the simplecgen branch? Make a copy of the develop branch and then add the simplecgen code to the root, but without the autotools stuff?

Currently, the existing main.c is only a very basic test program with no real functionality. It is not actually used during or after the build. I would love to have the default program output a binary which could be used to take in a template file as well as the template variables.

I don't think it's a simple copy/paste, we'll need to define a reasonable structure to submit the input data to the binary.

I am thinking something like:

./simplectemplate inputfile.html -k "key1" -v "value1" -k "key2" -v "value2"