Giter Club home page Giter Club logo

handlebars-petrovich4j's Introduction

handlebars-helpers-petrovich4j

Custom {{handlebars.java}} helper that enables Petrovich4j library usage

Petrovich-java

usage:

{{petrovich object formatString case='Accusative' gender=gender [firstName=name lastName=surname patronymic=patronymic]}}

or

{{petrovich formatString case='Dative' gender=gender firstName=name lastName=surname patronymic=patronymic}}

([*] - optional parameters)

Sample:

{{petrovich '{F} {I} {O}' case='Accusative' gender=user.gender
                    patronymic=user.middleName
                    lastName=user.lastName
                    firstName=user.name}}

will be rendered to user name in Accusative case with given format

formatString accepts:

  • {F} - surname in full form
  • {f} - surname in initials form
  • {I} - name in full form
  • {i} - name in initials form
  • {O} - patronymic in full form
  • {o} - patronymic in initials form
  • other character sequences keeps their state

Sample: '{F} {I} {O}' will rendered to string 'LastName Name Patronymic', '{F} {i}{o}' will rendered to string 'LastName N.P.'

By default petrovich helper tries to get next fields from object:

  • firstName (as name)
  • lastName (as surname)
  • patronymic (as patronymic) Can be override by directly passed hash-parameters (with such types)

Possible gender values:

  • MALE
  • FEMALE
  • resolve (case insensitive) - try to resolve gender by patronymic (Male will turn if cannot
  • any other will be passed to Petrovich as Gender.Both type

Petrovich gender conditional

Usage:

{{#if (is_gender patronymic_value test_gender)}}
  gender is equals
{{else}}
  gender not equals
{{/if}}

Where

  • patranymic_value is string with patronymic only (other parts of name cannot be used to resolve gender).
  • test_gender - string value with gender for equals block (male or female, case insensitive)

Some notes:

  • if gender is not correct - always else block will executed
  • if patronymic cannot be resolved for gender - male will be used as default

License

Project is available under Apache License 2

handlebars-petrovich4j's People

Contributors

webkumo avatar udav avatar

Watchers

James Cloos avatar  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.