Skip to content

silgy_add_to_static_res

Jurek Muszyński edited this page Sep 9, 2018 · 3 revisions

void silgy_add_to_static_res(const char *name, const char *src)

Description

Exposes string src as a static resource. Instead of using a file, you may sometimes want to generate something like CSS. Once you've added it, it's visible the same way the other statics are. src has to be a NULL-terminated string.

Returns

None

Example

#define COLOR_RED "#b40508"  // carefully crafted 'red' we want to use across
                             // the entire app, as well as many times in CSS

// ...

void create_css()  // called from app_init()
{
    char dsk[2048];
    char mob[2048];
    char dsk_min[2048];
    char mob_min[2048];

    // .w_border style used in .....
    sprintf(dsk, ".w_border {color:%s; border:1px solid grey;}", COLOR_RED);
    sprintf(mob, ".w_border {color:%s; border:2px solid grey;}", COLOR_RED);

    // .no_border style used in .....
    sprintf(dsk, " %s .no_border {color:%s; border:0;}", dsk, COLOR_RED);
    sprintf(mob, " %s .no_border {color:%s; border:0;}", mob, COLOR_RED);

    // ...

    silgy_minify(dsk_min, dsk);
    silgy_add_to_static_res("dsk.css", dsk_min);

    silgy_minify(mob_min, mob);
    silgy_add_to_static_res("mob.css", mob_min);
}
Clone this wiki locally