Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

ADRFranklin/pawn-templates

 
 

Repository files navigation

pawn-templates

sampctl

Description

Creates customizable templates, that can be rendered with custom variables.

Installation

Simply install to your project:

sampctl package install adrfranklin/pawn-templates

Include in your code and begin using the library:

#include <templates>

Usage

static Template:ban_template;

main() {
    Template_SetGlobalString("server", "name", "Example");
}

static RenderBanTemplate(playerid, const reason[])
{
    new name[MAX_PLAYER_NAME + 1];
    GetPlayerName(playerid, name, sizeof name);

    ban_template = Template_Create(
        "You have currently been banned from {{ server.name }}. \
        \
        Name: {{ name | capitalize }} \
        Date: {{ date | date: "%Y %h" }} \
        Admin {{ admin_name | capitalize }} \
        Reason: {{ reason }}"
    );

    Template_SetString(ban_template, "name", name);
    Template_SetInt(ban_template, "date", gettime());
    Template_SetString(ban_template, "admin_name", "Southclaws");
    Template_SetString(ban_template, "reason", reason);

    new output[1024];
    Template_Render(ban_template, output, sizeof output);
}

You can find more about the general syntax here: link

Testing

To test, simply run the package:

make test-native

or

task test-native

About

Template rendering for Pawn.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 67.1%
  • Pawn 25.7%
  • Makefile 6.1%
  • Dockerfile 1.1%