{"id":17698523,"url":"https://github.com/tattali/electron-twig","last_synced_at":"2025-03-31T01:13:24.001Z","repository":{"id":57221949,"uuid":"100045146","full_name":"tattali/electron-twig","owner":"tattali","description":"Electron module to render Twig templates ","archived":false,"fork":false,"pushed_at":"2019-04-08T10:11:01.000Z","size":10,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-10T05:54:35.675Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/electron-twig","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tattali.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-11T15:21:28.000Z","updated_at":"2023-07-10T06:58:51.000Z","dependencies_parsed_at":"2022-08-31T08:30:58.848Z","dependency_job_id":null,"html_url":"https://github.com/tattali/electron-twig","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattali%2Felectron-twig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattali%2Felectron-twig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattali%2Felectron-twig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattali%2Felectron-twig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tattali","download_url":"https://codeload.github.com/tattali/electron-twig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246399798,"owners_count":20770908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-24T15:09:42.662Z","updated_at":"2025-03-31T01:13:23.983Z","avatar_url":"https://github.com/tattali.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Electron Twig\n[![npm](https://img.shields.io/npm/v/electron-twig.svg)](https://www.npmjs.com/package/electron-twig)\n[![npm](https://img.shields.io/npm/dt/electron-twig.svg)](https://www.npmjs.com/package/electron-twig)\n[![David](https://img.shields.io/david/tattali/electron-twig.svg)](https://www.npmjs.com/package/electron-twig)\n\nGet [Twig.js](https://github.com/twigjs/twig.js) the JS implementation of the Twig Templating Language on [electron](https://github.com/atom/electron) projects.\n\nThis package is a simple `file protocol interceptor` which compiles files with `.twig` extension.\n\n## Installation\n\n```\nnpm install electron-twig\n```\n\n## Usage\n\n```js\nconst {app, BrowserWindow} = require('electron')\nconst twig                 = require('electron-twig')\n\napp.on('ready', () =\u003e {\n  let win = new BrowserWindow({width: 800, height: 600})\n\n  win.loadURL(`file://${__dirname}/views/index.html.twig`)\n\n  // etc.\n})\n```\n\nPut variables in template\n\n```js\nconst {app, BrowserWindow} = require('electron')\nconst twig                 = require('electron-twig')\n\napp.on('ready', () =\u003e {\n  let win = new BrowserWindow({width: 800, height: 600})\n\n  win.loadURL(`file://${__dirname}/views/index.html.twig`)\n  twig.view = {\n    foo: 'bar'\n  }\n\n  // etc.\n})\n```\n\nIf you have an error like that :\n```\nyou are using twig.js in sync mode in combination with async extensions\n```\n\nYou have to use the async version.\n\n\nFor async version add a variable `is_async: true`\n\n```js\nconst {app, BrowserWindow} = require('electron')\nconst twig                 = require('electron-twig')\n\napp.on('ready', () =\u003e {\n  let win = new BrowserWindow({width: 800, height: 600})\n\n  new Promise(function(resolve, reject) {\n    setTimeout(function() {\n      resolve();\n    }, 300);\n  }).then(() =\u003e {\n\n    win.loadURL(`file://${__dirname}/views/index.html.twig`)\n    twig.view = {\n      foo: 'bar',\n      is_async: true\n    }\n\n  });\n\n  // etc.\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftattali%2Felectron-twig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftattali%2Felectron-twig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftattali%2Felectron-twig/lists"}