Giter Club home page Giter Club logo

crustache's Introduction

▒▒▒░░░░░░░░░░▄▐░░░░
▒░░░░░░▄▄▄░░▄██▄░░░
░░░░░░▐▀█▀▌░░░░▀█▄░
░░░░░░▐█▄█▌░░░░░░▀█▄
░░░░░░░▀▄▀░░░▄▄▄▄▄▀▀
░░░░░▄▄▄██▀▀▀▀░░░░░
░░░░█▀▄▄▄█░▀▀░░░░░░
░░░░▌░▄▄▄▐▌▀▀▀░░░░░
░▄░▐░░░▄▄░█░▀▀░░░░░
░▀█▌░░░▄░▀█▀░▀░░░░░
░░░░░░░░▄▄▐▌▄▄░░░░░
░░░░░░░░▀███▀█░▄░░░
░░░░░░░▐▌▀▄▀▄▀▐▄░░░
░░░░░░░▐▀░░░░░░▐▌░░
░░░░░░░█░░░░░░░░█░░
░░░░░░▐▌░░░░░░░░░█░ 

crustache's People

Contributors

vladimir-vg avatar vmg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

crustache's Issues

Output stops after first variable is replaced

This may very well be a problem with my implementation of the API. I'm currently just trying to make every variable get replaced with a single string ("TEST VARIABLE"). Seems like it should be pretty straightforward.

Here is the test template I'm using:

<article class="post">
    <header class="post-header">
        <h1><a href="{{url}}" title="[Permalink] {{title}}">{{title}}</a></h1>
        <span class="date">{{date}}</span>
    </header>
    <section class="post-content">
        {{content}}
    </section>
    <p class="continue-reading"><a href="{{url}}">Continue reading &raquo;</a></p>
</article>

And here is the relevant part of my implementation:

int TriboCrustacheGetVariable(crustache_var *variable, void *context, const char *key, size_t keySize) {
    printf("Get variable: %s.\n", strndup(key, keySize));
    variable->type = CRUSTACHE_VAR_STR;
    variable->data = (void *)"TEST VAR";
    variable->size = sizeof("TEST VAR");
    return 0;
}

And then the code that uses the API:

crustache_template *pageTemplate;
crustache_new(&pageTemplate, &api, buffer, length);

struct buf *outputBuffer = bufnew(128);
crustache_var context = {
    .type = CRUSTACHE_VAR_CONTEXT
};
int error = crustache_render(outputBuffer, pageTemplate, &context);
if (error) {
    printf("Render error: %s\n", crustache_strerror(error));
}

printf("\nOutput data:\n%s\n", outputBuffer->data);
bufrelease(outputBuffer);

When run, this code prints the following:

Get variable: url.
Get variable: title.
Get variable: title.
Get variable: date.
Get variable: content.
Get variable: url.

Output data:

<article class="post">
    <header class="post-header">
        <h1><a href="TEST VAR

So the get variable function gets called the right number of times, but for some reason the output only continues until the first variable. Any idea what is going wrong?

License?

What license is this code being released under?

wrong variable type with Integer

#!/usr/bin/ruby
require 'mustache'
require_relative 'crustache.rb/lib/crustache'

list = [{:bar => 1000}]
doc  = '{{#list}}{{bar}}{{/list}}'

puts Mustache.render(doc, :list => list) 
# => 1000

puts Crustache::Template.new(doc).render("list" => list)
# => benchmarks/crust.rb:8:in `render': Wrong variable type fetched from context ({{bar}}, <Variable @ 0x7fa25a5e81e0>) (Crustache::RenderError) from benchmarks/crust.rb:8:in `<main>'

Would be maybe nice to have same behavior?

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.