New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

xls-report-ex

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xls-report-ex

The template engine for generate xlsx documents

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Excel Шаблонизатор

Поддерживаемые файлы: xlsx

Синтаксис

Поддерживается 2 вида выражений:

  • Вывод значения переменной: {{value|pipe:arg1:argN}}
  • Вывод массива переменных: [[value|pipe:arg1:argN]]

Где:

  • value - некоторое значение или массив
  • pipe - некоторая функция дополнительной обработки значения
  • arg1, argN - агрументы/параметры передаваемые в функцию обработки значения

Реализованные варианты выражений

  • {{propertyName}} - вывод значения без обработки

  • {{propertyName|date}} - значение форматируется как дата

  • {{fileName|image}} - производится поиск картинки по имени файла. Если картинка найдена, то она встраивается в ячейку таблицы

  • {{propertyArrayName|find:propertyName:propertyValue}} - поиск объекта в массиве propertyArrayName у которого есть свойство propertyName равное propertyValue

  • {{propertyObjectName|get:propertyName}} - возвращает значение свойства propertyArrayName из объекта propertyObjectName

  • [[array|repeat-rows:3]] - обрабатать массив переменных и вывести его содержимое в секцию из 3 строк начиная с текущей. Строки будут продублированы в соответствии с размером массива.

  • [[array|filter:propertyName:checkValue]] - отфильтровать массив. Если указано только propertyName, то на выходе получим массив с объектами содержащими это поле. Если указано propertyName и checkValue, то на выходе получим массив с объектами которые содержат свойство propertyName равное checkValue.

Примеры

Будем выводить в шаблонизаторе такие данные:

let data = {
    reportBuildDate: 1526443275041,

    results: [
        { text: 'some text 1', answerText: 'a text of an answer 1'},
        { text: 'some text 2', answerText: 'a text of an answer 2'},
        { text: 'some text 3', answerText: 'a text of an answer 3'},
        { answerText: 'a text of an answer 3'},
    ],
};

Составим шаблон:

!!! В данном примере / указано вместо |

AB
{{reportBuildDate/date}}{{results/find:text:some text 2/get:answerText}}
[[results/filter:text/repeat-rows:1]] {{text}}{{answerText}}

Получим результат:

AB
16.05.2018a text of an answer 2
some text 1a text of an answer 1
some text 2a text of an answer 2
some text 3a text of an answer 3

FAQs

Package last updated on 18 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc