{"id":22394162,"url":"https://github.com/atlantis-software/docmake","last_synced_at":"2025-07-31T10:32:32.187Z","repository":{"id":42450698,"uuid":"362820117","full_name":"Atlantis-Software/docmake","owner":"Atlantis-Software","description":"document templating language library for javascript","archived":false,"fork":false,"pushed_at":"2022-05-24T07:51:43.000Z","size":482,"stargazers_count":0,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-06T18:45:53.774Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Atlantis-Software.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":"2021-04-29T13:05:24.000Z","updated_at":"2021-12-31T09:53:29.000Z","dependencies_parsed_at":"2022-08-28T17:13:29.131Z","dependency_job_id":null,"html_url":"https://github.com/Atlantis-Software/docmake","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Atlantis-Software/docmake","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atlantis-Software%2Fdocmake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atlantis-Software%2Fdocmake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atlantis-Software%2Fdocmake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atlantis-Software%2Fdocmake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Atlantis-Software","download_url":"https://codeload.github.com/Atlantis-Software/docmake/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atlantis-Software%2Fdocmake/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268024593,"owners_count":24183149,"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","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-12-05T05:09:13.301Z","updated_at":"2025-07-31T10:32:31.890Z","avatar_url":"https://github.com/Atlantis-Software.png","language":"JavaScript","readme":"# docmake\ndocmake is a document templating language library for javascript.\n\n## Installation\n\nInstallation uses the [npm](http://npmjs.org/) package manager.  Just type the following command after installing npm.\n\n    npm install docmake\n\n## usage\n\n```javascript\nvar Docmake = require('docmake');\nvar fs = require('fs');\n\nvar doc = new Docmake();\ndoc.compile('{{hello}}', { hello: 'hello world!' }, function(err) {\n  if (err) {\n    return console.log(err);\n  }\n  doc.getPdf().pipe(fs.createWriteStream('document.pdf')); \n});\n```\n\ndoc.compile takes three arguments:\n* template: a string containing the template\n* scope: an object containing data used in template\n* cb: a callback\n\ndoc.getPdf takes one optional argument:\n* options: an object describing document shape\nreturn a pdf document stream\n\ndoc.getPcl takes one optional argument:\n* options: an object describing document shape\nreturn a pcl document stream\n\noptions:\n* size: document format, default 'A4'\n* margins: pages margins containing left, top, right and bottom margin, default {left: 10, top: 10, right: 10, bottom: 10}\n\n## template language\n\ndocmake simple expressions starts with `{{` , some content, and ends with `}}`.\nwhen the document is rendered with the template, the expression is evaluated and the value is printed in the document.\nin the previous exemple, `{{hello}}` expression is replaced by the corresponding value in the scope.\n\n### nested object scope\n\nSometimes, scope contains other objects or arrays. For example:\n\n```javascript\n{\n  person: {\n    firsname: \"Alexandre\",\n    lastname: \"Tiertant\"\n  }\n}\n```\n\nIn such a case, you can use a dot-notation to gain access to the nested properties\n\n```javascript\n{{person.firstname}}\n{{person.lastname}}\n```\n\n### text\n\nText tag starts with `{{text`, a text, some attributes , and ends with `}}`.\n\n\n```javascript\n{{text person.firstname fontSize=24}}\n{{text \"some text here\" bold=true}}\n```\n\navailable attributes for text:\n* font: (string) name of the font\n* fontSize: (number) size of the font in pt\n* lineHeight: (number) the line height (default: 1)\n* bold: (boolean) whether to use bold text (default: false)\n* italics: (boolean) whether to use italic text (default: false)\n* characterSpacing: (number) size of the letter spacing in pt\n* color: (string) the color of the text (color name e.g., ‘blue’ or hexadecimal color e.g., ‘#ff5500’)\n* decoration: (string) the text decoration to apply (‘none’ or ‘underline’ or ‘strike’)\n* alignment: (string) (‘left’ or ‘center’ or ‘right’) the alignment of the text\n* valignment: (string) (‘top’ or ‘center’ or ‘bottom’) the vertical alignment of elements if height is defined.\n* width: (number or string containing a number and ends with `%`) width of the text\n* height: (number or string containing a number and ends with `%`) height of the text\n* fillColor: (string) the background color of the text\n* margin: ([left, top, right, bottom], [horizontal, vertical], number equalLeftTopRightBottom) space arround the text\n* border: ([left, top, right, bottom], [horizontal, vertical], number equalLeftTopRightBottom) size of the border\n\n### comment\n\ncomments can be used to explain template code, and to make it more readable.\nAny text between // and the end of the line will be ignored by template (will not be executed).\n\n```javascript\n// some comment here\n```\n\n### image\n\nImage tag starts with `{{image`, an image jpg or png (filepath or buffer or base64 string), and ends with `}}`.\n\n```javascript\n{{image \"/home/user/image.png\"}}\n```\n\navailable attributes for image:\n* width: (number or string containing a number and ends with `%`) width of the image\n* height: (number or string containing a number and ends with `%`) height of the image\n* alignment: (string) (‘left’ or ‘center’ or ‘right’) the alignment of the image\n\n### svg\n\nSvg tag starts with `{{svg`, an svg image (filepath or string), and ends with `}}`.\n\n```javascript\n{{svg \"/home/user/image.svg\"}}\n```\n\navailable attributes for svg:\n* width: (number or string containing a number and ends with `%`) width of the svg\n* height: (number or string containing a number and ends with `%`) height of the svg\n* alignment: (string) (‘left’ or ‘center’ or ‘right’) the alignment of the svg\n\n### barcode\n\nBarcode tag starts with `{{barcode`, a string value, and ends with `}}`.\n\n```javascript\n{{barcode \"this is a barcode\"}}\n```\n\navailable attributes for qr:\n* width: (number or string containing a number and ends with `%`) width of the barcode\n* height: (number or string containing a number and ends with `%`) height of the barcode\n* alignment: (string) (‘left’ or ‘center’ or ‘right’) the alignment of the barcode\n\n### qr\n\nQr tag starts with `{{qr`, a string value, and ends with `}}`.\n\n```javascript\n{{qr \"this is a qrcode\"}}\n```\n\navailable attributes for qr:\n* width: (number or string containing a number and ends with `%`) width of the qrcode\n* height: (number or string containing a number and ends with `%`) height of the qrcode\n* alignment: (string) (‘left’ or ‘center’ or ‘right’) the alignment of the qrcode\n\n### columns\n\nby default, elements are placed one below other. using columns, elements are placed horizontally.\nthe tag `{{#columns}}` require a closing tag `{{/columns}}`.\n\n```javascript\n{{#columns widths=[\"auto\", 25, \"*\"]}}\n  {{text \"column one\"}}\n  {{text \"column two\"}}\n  {{text \"column three\"}}\n{{/columns}}\n```\n\navailable attributes for columns:\n* columnGap: (number) specify gap (space) between columns\n* width: (number or string containing a number and ends with `%`) total width of the columns\n* widths: (array) width of each column that could be:\n  * a number: fixed width\n  * a string containing a number and ends with `%`: a percent of total width\n  * \"auto\": auto-sized columns have their widths based on their content\n  * \"*\": star-sized columns fill the remaining space. if there's more than one star-column, available width is divided equally\n* font: (string) name of the font\n* fontSize: (number) size of the font in pt\n* lineHeight: (number) the line height (default: 1)\n* bold: (boolean) whether to use bold text (default: false)\n* italics: (boolean) whether to use italic text (default: false)\n* characterSpacing: (number) size of the letter spacing in pt\n* color: (string) the color of the text (color name e.g., ‘blue’ or hexadecimal color e.g., ‘#ff5500’)\n* decoration: (string) the text decoration to apply (‘none’ or ‘underline’ or ‘strike’)\n* alignment: (string) (‘left’ or ‘center’ or ‘right’) the alignment of the columns\n* valignment: (string) (‘top’ or ‘center’ or ‘bottom’) the vertical alignment of elements in columns.\n* fillColor: (string) the background color of the columns\n* margin: ([left, top, right, bottom], [horizontal, vertical], number equalLeftTopRightBottom) space arround columns element\n* border: ([left, top, right, bottom], [horizontal, vertical], number equalLeftTopRightBottom) size of the border\n\n### stack\n\nin columns, elements are placed horizontally, using stack, elements are placed vertically.\nthe tag `{{#stack}}` require a closing tag `{{/stack}}`.\n\n```javascript\n{{#stack}}\n  {{text \"top\"}}\n  {{text \"middle\"}}\n  {{text \"bottom\"}}\n{{/stack}}\n```\n\navailable attributes for stack:\n* width: (number or string containing a number and ends with `%`) total width of the stack\n\n### table\n\ntables allow you to arrange elements into rows and columns of cells.\ntable element starts with tag `{{#table}}` and ends with `{{/table}}`, it must contain one or more row element.\nrow element starts with tag `{{#row}}` and ends with `{{/row}}`, it must contain one or more header or column element.\nheader element starts with tag `{{#header}}` and ends with `{{/header}}`.\ncolumn element starts with tag `{{#column}}` and ends with `{{/column}}`.\n\n\n```javascript\n{{#table width=\"75%\" repeatHeader=true}}\n  {{#row}}\n    {{#header}}\"firstname\"{{/header}}\n    {{#header}}\"lastname\"{{/header}}\n  {{/row}}\n  {{#row}}\n    {{#column}}\"Alexandre\"{{/column}}\n    {{#column}}\"Tiertant\"{{/column}}\n  {{/row}}\n{{/table}}\n```\n\navailable attributes for table:\n* repeatHeader: (boolean) repeat headers on page break when true\n* width: (number or string containing a number and ends with `%`) total width of the table\n* widths: (array) width of each column that could be:\n  * a number: fixed width\n  * a string containing a number and ends with `%`: a percent of total width\n  * \"auto\": auto-sized columns have their widths based on their content\n  * \"*\": star-sized columns fill the remaining space. if there's more than one star-column, available width is divided equally\n\navailable attributes for table, row, header and columns:\n* colspan: (number) specifies the number of columns the cell should span\n* rowspan: (number) specifies the number of rows the cell should span\n* font: (string) name of the font\n* fontSize: (number) size of the font in pt\n* lineHeight: (number) the line height (default: 1)\n* bold: (boolean) whether to use bold text (default: false)\n* italics: (boolean) whether to use italic text (default: false)\n* characterSpacing: (number) size of the letter spacing in pt\n* color: (string) the color of the text (color name e.g., ‘blue’ or hexadecimal color e.g., ‘#ff5500’)\n* decoration: (string) the text decoration to apply (‘none’ or ‘underline’ or ‘strike’)\n* alignment: (string) (‘left’ or ‘center’ or ‘right’) the alignment of the elements in it.\n* valignment: (string) (‘top’ or ‘center’ or ‘bottom’) the vertical alignment of elements in it.\n* fillColor: (string) the background color of the element\n* margin: ([left, top, right, bottom], [horizontal, vertical], number equalLeftTopRightBottom) space arround element\n* border: ([left, top, right, bottom], [horizontal, vertical], number equalLeftTopRightBottom) size of the border\n\n### hspace and vspace\nhspace tag add an horizontal space wheras vspace add a vertical one.\nthey only take one integer size parameter.\n\n```javascript\n{{hspace 100}}\n{{vspace 50}}\n```\n\n### style\n\nStyle tag add some basic css style to document\nStyle tag starts with `{{style`, a simple css string, and ends with `}}`.\ndocmake css implement tag, class(.), id(#) selector\n\n```javascript\n{{style \"text { color=#FF0000; }\"}}\n{{text \"all text are displayed in red\"}}\n```\n\n### class\n\nClass tag define a class that can be applyed to any element.\nClass tag starts with `{{class`, a class name string, some attributes, and ends with `}}`.\n\n```javascript\n{{class \"red\" color=\"#FF0000\"}}\n{{text \"text displayed in red\" class=[\"red\"]}}\n```\n\n### font\n\nFont tag add .ttf files as font\nFont tag starts with `{{font`, a font name string, some attributes, and ends with `}}`.\n\n```javascript\n{{font myFont normal=\"/home/user/myfont.ttf\"}}\n{{text \"text displayed in red\" class=[\"red\"]}}\n```\n\navailable attributes for font:\n* normal: (string) .ttf filepath for normal text\n* bold: (string) .ttf filepath for bold text\n* italics: (string) .ttf filepath for italics text\n* bolditalics: (string) .ttf filepath for bold and italics text\n\n### page header and page footer\n\ncontents of page header and page footer are repeat on each page on top for page header and at the bottom for page footer.\ntext `{{currentPage}}` in page footer is replaced by the number of the current page.\ntext `{{pageCount}}` in page footer is replaced by the count of pages.\n\n```javascript\n{{#pageHeader}}\n  {{image \"/home/user/header.png\" width=\"100%\"}}\n{{/pageHeader}}\n{{#pageFooter}}\n  {{image \"/home/user/footer.png\" width=\"100%\"}}\n  {{text \"{{currentPage}} / {{pageCount}}\" alignment=\"right\"}}\n{{/pageFooter}}\n```\n### page break\n\n`{{pageBreak}}` tag move to the next page.\n\n### reset page count\n\n`{{resetPageCount}}` tag break the page and reset the number of page and page count.\n\n### if\n\nIf tag include its contents in document only if a condition is satisfied.\nIf tag starts with `{{#if `, a conditional expression, and ends with `}}`.\nIf tag must be close with tag `{{/if}}`\n\n```javascript\n{{#if person.firstname == \"Alexandre\"}}\n  {{person.firstname}}\n{{/if}}\n```\n\n### each\n\nEach tag include its contents in document once for each element in an array, in order and replace scope by it.\n\n```javascript\n{\n  my_array: [\n    {\n      data: \"first\"\n    },\n    {\n      data: \"second\"\n    }\n  ]\n}\n```\n\n```javascript\n{{#each my_array}}\n  {{data}}\n{{/each}}\n```\n\ninside a Each tag, some keywords could be used:\n\n* `$root` to access root scope.\n* `$item` to access current iteration item.\n* `$key` to access the current key in object iteration (same as $index in array).\n* `$index` to access the index of the iterated item.\n* `$first` only true on first iteration.\n* `$last` only true on last iteration.\n\n```javascript\n{{#each [\"1\",\"2\",\"3\"]}}\n  {{#if $first}}\n    {{text \"first\"}}\n  {{/if}}\n  {{text concat(\"item: \", $item, \" index: \", $index)}}\n  {{#if $last==true}}\n    {{text \"last\"}}\n  {{/if}}\n{{/each}}\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatlantis-software%2Fdocmake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatlantis-software%2Fdocmake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatlantis-software%2Fdocmake/lists"}