Code Monkey home page Code Monkey logo

butterknife's Introduction

butterknife

A simple HTML Templating Engine for C.

Butterknife is blade template (https://laravel.com/docs/10.x/blade) like system for templating and rendering HTML.

Technology

use

Install with CLib or copy butterknife.c and butterknife.h and the deps folder into your project.

clib install

If you are including any of the above libraries elsewhere add this compiler flag

-D BK_DEPENDENCY

As well add the following to your root C file (this assumes you are using include flags:-Ideps -Ideps/cwalk):

#include <fs/fs.c>
#include <tiny-regex-c/re.c>
#include <cwalk/cwalk.c>
#include <vec/vec.c>

After which you can create a basic layout:

<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
<body>
    @yields content;
</body>
    @yields footer;
</html>

And a basic page:

@layout layout.bk.html;
@head
    <title>page</title>
@headclose
@section content 
<div>
    <h1>Butterknife</h1>
    <p>Here is a butterknife section called content.</p>
</div><!--Content Div-->
@sectionclose
@section footer
<footer>
<p>Copyright 2023.</p>
</footer>
@sectionclose

If our example code in in the ./example directory (hint hint) we could use the following program to render the page and output it the console.

#include "butterknife.c"

int main()
{
    buffer_t* page = bk_generate_webpage("./example/page.bk.html");
    printf("Page: \n%s\n", page->data);
}

To build and run:

gcc app.c -o app
./app

Built-in debugging [WIP]

In butterknife.h uncomment:

#define BK_DEBUG

butterknife's People

Contributors

phoenixpinpoint avatar

Stargazers

Roman Alexander Davis avatar

Watchers

 avatar

butterknife's Issues

Add Cast to (int) on getTag Return

./src/../deps/butterknife/butterknife.c:241:67: error: incompatible pointer to integer conversion passing 'void *' to parameter of type 'int' [-Wint-conversion]
241 | htmlPage = bk_buffer_t_insert(htmlPage, pageData, getTag.data[1], (int)getTag.data[1]+(int)getTag.data[2]);

When using cwalk I must changed the cwalk.c file to use #include "cwalk".h

When installing default cwalk library the code looks in the system for cwalk and not in the local file system.

The reason for this is that cwalk is using an standard library include reference not a local include reference. The right answer is to move the include on the local users system to that location.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.