Last active
February 17, 2019 22:53
-
-
Save andybp85/2075671e6403e7c85f19ae2cf3f35fdb to your computer and use it in GitHub Desktop.
Sass_Data_Context example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include "sass/context.h" | |
int main( int argc, char* argv[] ) | |
{ | |
// get the input file from first argument or use default | |
char* input = argc > 1 ? argv[1] : "div { a { color: blue; } }"; | |
// create the context and get all related structs | |
struct Sass_Data_Context* data_ctx = sass_make_data_context(strdup(input)); | |
struct Sass_Context* ctx = sass_data_context_get_context(data_ctx); | |
struct Sass_Options* ctx_opt = sass_context_get_options(ctx); | |
// configure some options ... | |
sass_option_set_precision(ctx_opt, 10); | |
// context is set up, call the compile step now | |
int status = sass_compile_data_context(data_ctx); | |
// print the result or the error to the stdout | |
if (status == 0) puts(sass_context_get_output_string(ctx)); | |
else puts(sass_context_get_error_message(ctx)); | |
// release allocated memory | |
sass_delete_data_context(data_ctx); | |
// exit status | |
return status; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment