Skip to content

aliyr/vue-persian-filters

Repository files navigation

vue-persian-filters

a vue plugin for filtering strings and arrays

installation

npm :

npm install vue-persian-filters

When used with a module system, you must explicitly install the filters via Vue.use() :

import vuePersianFilters from "vue-persian-filters"
import Vue from "vue"

Vue.use(vuePersianFilters);

Usage

toPersianNumber

  • Example:

    {{ msg | toPersianNumber }} // '1234' => '۱۲۳۴'

toPersianDate

  • Arguments:

    • {String} [format] - default : null
  • Examples:

    {{ date | toPersianDate('dddd') }} // '3/5/95' => 'یک‌شنبه'
    {{ date | toPersianDate('MMM YY') }} // new Date() => '۱۳۹۷ دی' 
    {{ date | toPersianDate('hh:mm:ss') }} // new Date() => '۰۲:۰۳:۲۲' 

    hint: toPersianDate filter uses moment.js date formats, So fill free to Use any of date formats that Moment gives to you

toRelativeDate

  • Example:

    {{ msg | toRelativeDate }} // 'new Date()' => ‫‫‫‫۴ دقیقه پیش 

toPersianCurrency

  • Arguments:

    • {String} [currency] - default : 'ریال'
    • {Number} [decimalLimit] - default : 2
    • {Object} [Options]
  • Options:

    • {String} [separator] - default : ','
    • {String} [decimalSeparator] - default : '.'
  • Examples:

    {{num | toPersianCurrency }} // -1243234.588 =>‫     ‫۱,۲۴۳,۲۳۴.۵۹- ریال 
    // cur = 'تومان'
    
    {{num | toPersianCurrency(cur, 1) }} // -1243234.588 =>‫     ۱,۲۴۳,۲۳۴.۶- تومان‫ 
    // cur = 'مگابایت'
      
    {{num | toPersianCurrency(cur, 1 , {separator: '.', decimalSeparator: ','}) }} // 1243234.588 =>‫     ۱.۲۴۳.۲۳۴,۶ مگابایت 

toPersianDigits

  • Example:

    {{num | toPersianDigits }} // 1534221 => ‫  ‫یک میلیون و پانصد و سی و چهار هزار و دویست و بیست و یک 

    Hint: Decimal and negative numbers not supported by toPersianDigits yet, but we try to implement it in newer versions :)

toPersianTruncate

  • Arguments:

    • {Number} [characterLimit] - default : 10
  • Example:

    {{num | toPersianTruncate(28) }} // در اداره ی شهرداری جنوب تهران => ‫ در اداره ی شهرداری جنوب ...

About

a vue plugin for filtering strings and arrays

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published