Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom templates JSON #376

Merged
merged 8 commits into from
Oct 8, 2024
Merged

Custom templates JSON #376

merged 8 commits into from
Oct 8, 2024

Conversation

nzagorchev
Copy link
Contributor

@nzagorchev nzagorchev commented Sep 21, 2024

Overview

Add registering of custom templates through a JSON definition

Implementation

Implement CTJsonTemplateProducer.

Example usage

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"template-definitions" ofType:@"json"];
NSString *definitionsJson = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
TemplatePresenter *presenter = [[TemplatePresenter alloc] init];
CTJsonTemplateProducer *producer = [[CTJsonTemplateProducer alloc] initWithJson:definitionsJson 
    templatePresenter:presenter functionPresenter:presenter];
[CTCustomTemplatesManager registerTemplateProducer:producer];

template-definitions.json

{
  "template-1": {
    "type": "template",
    "arguments": {
      "var1": {
        "type": "boolean",
        "value": false
      },
      "var2": {
        "type": "string",
        "value": "Default"
      },
      "folder1": {
        "type": "object",
        "value": {
          "var3": {
            "type": "number",
            "value": 0
          }
        }
      },
      "folder1.var4": {
        "type": "file"
      },
      "map": {
        "type": "object",
        "value": {
          "int": {
            "type": "number",
            "value": 0
          },
          "string": {
            "type": "string",
            "value": "Default"
          }
        }
      },
      "action": {
        "type": "action"
      }
    }
  },
  "function-1": {
      "type": "function",
      "isVisual": "true",
      "arguments": {
          "bool": {
              "type": "boolean",
              "value": true
          },
          "string": {
              "type": "string",
              "value": "Default"
          }
      }
  }
}

@nzagorchev nzagorchev marked this pull request as ready for review October 2, 2024 20:19
@nzagorchev nzagorchev merged commit 2cc3e98 into develop Oct 8, 2024
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants