Generalized the handlebars code.
This commit is contained in:
24
src/util/string.h
Normal file
24
src/util/string.h
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (c) 2021 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include <dawn/dawn.h>
|
||||
|
||||
/**
|
||||
* Replaces handlebars within the string with items from the list of variables.
|
||||
* Output of replacement is stored in the buffer provided. Handlebars within the
|
||||
* string should be in the format of; "{{ key }}", spaces within the bars will
|
||||
* be skipped. Variable keys cannot exceed STRING_HANDLEBAR_KEY_MAXLENGTH in
|
||||
* length.
|
||||
*
|
||||
* @param string String to parse.
|
||||
* @param variables Variables to use in the parsing.
|
||||
* @param variableCount How many variables in the array.
|
||||
* @param buffer Buffer to write characters in to.
|
||||
* @return The count of characters that were written to the buffer.
|
||||
*/
|
||||
int32_t stringHandlebarsBuffer(char *source,
|
||||
stringhandlebarvariable_t *variables, int32_t variableCount, char *buffer
|
||||
);
|
Reference in New Issue
Block a user