Strings

Description

This example shows use of the WebC strings. Normally when enter a HTML block WebC wraps that block with a wcecho(). You can also end a block with a =?>. This marks the HTML block as a string. Instead of a wcecho() instead the block will only be quoted into a string.

WebC Code

<?wc
const char *HTML = =?><p>
This is all HTML.  You can use things like "quotes" and newlines
and it will be added to the C string.
</p><? ;
?>
<!DOCTYPE HTML>
<html>
    <head>
        <title>Strings</title>
    </head>
    <body>
        <? wcecho(HTML); ?>
    </body>
</html> 

C Code

#include "WCWebAPI.h"

const char *HTML = "<p>\n"
        "This is all HTML.  You can use things like \"quotes\" and newlines\n"
        "and it will be added to the C string.\n"
        "</p>";

void Page_Strings(void)
{
    wcecho("<!DOCTYPE HTML>\n"
        "<html>\n"
        "   <head>\n"
        "       <title>Strings</title>\n"
        "   </head>\n"
        "   <body>\n");
    wcecho(HTML);
    wcecho("   </body>\n"
        "</html>\n");
}

Output

<!DOCTYPE HTML>
<html>
   <head>
       <title>Strings</title>
   </head>
   <body>
        <p>
        This is all HTML.  You can use things like "quotes" and newlines
        and it will be added to the C string.
        </p>
   </body>
</html>