Git Product home page Git Product logo

apress-handlebars-helpers's Introduction

apress-handlebars-helpers

Набор межпроектных handlebars хелперов

install

  1. Убедиться, что рядом с package.json в геме или проекте есть файл конфигурации .npmrc с ссылкой на внутренний registry:

    registry = https://registry.railsc.ru
    
  2. Установить через npm:

    npm install @apress/handlebars-helpers --save-dev
    

usage

  1. Убедиться, что установлены следующие пакеты:

    • handlebars
    • handlebars-loader
  2. В конфиг вебпака добавить настройки handlebars-loader с указанием абсолютного пути до наших хелперов:

    const path = require('path');
    // ...
    module.exports = {
      // ...
      {
        test: /\.handlebars$/,
        loader: 'handlebars-loader',
        query: { helperDirs: [ path.dirname(require.resolve('@apress/handlebars-helpers')) + '/helpers' ] }
      },
      // ...
    };
  3. Теперь, в шаблонах станут доступны хелперы из apress-handlebats-helpers. Например:

    <div>
      {{i18n 'path.to.locale.string'}}
    </div>
    

    где:

    • i18n - название хелпера (совпадает с названием файла в @apress/helpers/helpers)
    • 'path.to.locale.string' - аргумент, передаваемый в хелпер (в нашем случае это строка)

repository structure

  • helpers/ - handlebars хелперы
  • test/ - юнит тесты на хелперы
    • helperName.js/ - юнит тесты конкретного хелпера
      • helperName.js - код юнит тестов конкретного хелпера
      • helper.js - вспомогательные функции для тестирования конкретного метода

contribute

  • При добавлении нового хелпера или изменении существующего, необходимо дорабатывать/добавлять юнит тесты.
    • для запуска тестов npm run test
    • для запуска тестов в режиме разработки npm run test-watcher
    • для запуска проверки процента покрытия тестами npm run test-coverage

apress-handlebars-helpers's People

Contributors

egorovechkin avatar idbolshakov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.