generating an HTML email body using onion templates

17 views
Skip to first unread message

Basile Starynkevitch

unread,
Nov 26, 2019, 10:05:14 AM11/26/19
to onion-dev
Hello All,

In my Bismon software (GPLv3+), file web_ONIONBM.c function do_forgot_email_onion_handler_BM  (near line 1580 of git commit e3373aec2aafd26cf86) I am extremely tempted to abuse a little libonion by using its template system to generate the HTML5 body of a generated email (for forgot password situation) after having replyied with another template expansion using the same common onion_dict pointer.

Is it reasonable to do so?

I want to avoid having too much template systems in Bismon.

Regards.
--
Basile Starynkevitch - http://starynkevitch.net/Basile/
Bourg La Reine, near Pairs, France
(all opinions are mines only, not from my employer or funding organsations)

David Moreno Montero

unread,
Nov 27, 2019, 2:57:11 AM11/27/19
to Basile Starynkevitch, onion-dev
IMHO it's very reasonable to do. I do similar things sometimes.

Just think about if anybody but you try to modify the code, will this person understand what you did there? (A code comment may suffice)

Regards,
David


--
You received this message because you are subscribed to the Google Groups "onion-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to onion-dev+...@coralbits.com.
To view this discussion on the web visit https://groups.google.com/a/coralbits.com/d/msgid/onion-dev/48d3601b-8074-4949-9338-5c97840ac612%40coralbits.com.

Basile Starynkevitch

unread,
Nov 27, 2019, 8:58:56 AM11/27/19
to David Moreno Montero, onion-dev


On 11/27/19 8:56 AM, David Moreno Montero wrote:
IMHO it's very reasonable to do. I do similar things sometimes.


It seems to me that the following  trivial function is then lacking:

const char* 
onion_response_raw_buffer (onion_response*resp) {
  if (resp) return resp->buffer;
  return NULL;
}


Can I suggest adding it?

--
Basile STARYNKEVITCH   == http://starynkevitch.net/Basile
opinions are mine only - les opinions sont seulement miennes
Bourg La Reine, France; <bas...@starynkevitch.net>
(mobile phone: cf my web page / voir ma page web...)

Basile Starynkevitch

unread,
Nov 27, 2019, 9:44:56 AM11/27/19
to onio...@coralbits.com


On 11/27/19 2:58 PM, Basile Starynkevitch wrote:


On 11/27/19 8:56 AM, David Moreno Montero wrote:
IMHO it's very reasonable to do. I do similar things sometimes.


It seems to me that the following  trivial function is then lacking:

const char* 
onion_response_raw_buffer (onion_response*resp) {
  if (resp) return resp->buffer;
  return NULL;
}


Can I suggest adding it?


An alternative might be to extend onion_response to accept an abstract type, defined by a generic pointer and callbacks.

In my particular case, I would use a provided FILE* pointer, all callbacks doing fprintf, fputs etc... on it. That FILE* would be (in my case) obtained on Linux with open_memstream.


But then the name onion_response is no more appropriate.


Actually, I am very tempted to use some other C "templated string" machinery. Does anyone know one here?

Cheers

Basile Starynkevitch

unread,
Nov 27, 2019, 10:05:24 AM11/27/19
to onio...@coralbits.com


On 11/27/19 3:44 PM, Basile Starynkevitch wrote:


On 11/27/19 2:58 PM, Basile Starynkevitch wrote:


On 11/27/19 8:56 AM, David Moreno Montero wrote:
IMHO it's very reasonable to do. I do similar things sometimes.


It seems to me that the following  trivial function is then lacking:

const char* 
onion_response_raw_buffer (onion_response*resp) {
  if (resp) return resp->buffer;
  return NULL;
}


Can I suggest adding it?


An alternative might be to extend onion_response to accept an abstract type, defined by a generic pointer and callbacks.

In my particular case, I would use a provided FILE* pointer, all callbacks doing fprintf, fputs etc... on it. That FILE* would be (in my case) obtained on Linux with open_memstream.


But then the name onion_response is no more appropriate.


Actually, I am very tempted to use some other C "templated string" machinery. Does anyone know one here?


mmdmoidur...@gmail.com

unread,
Jul 12, 2020, 6:11:51 AM7/12/20
to onion-dev

mmdmoidur...@gmail.com

unread,
Jul 12, 2020, 6:12:10 AM7/12/20
to onion-dev
On Tuesday, 26 November 2019 20:35:14 UTC+5:30, Basile Starynkevitch wrote:
https://groups.google.com/a/coralbits.com/d/msg/onion-dev/jbglkVofb_E/Zs6Sp15jBgAJ
Reply all
Reply to author
Forward
0 new messages