Git Product home page Git Product logo

vuejs-suglify's Introduction

Slugify VueJs

A Vue component that slugify your v-model inputs We make a little changement so you can handle the input with your own stuff.

Demo

Demo

Installation :

npm install vue-suglify

Getting Started

In your script entry point:

window.Vue = require("vue");

import VueSuglify from "vue-suglify";

//Vue.component("suglify", VueSuglify); If you want a global Component

const app = new Vue({
  el: "#app",
  components: {
    VueSuglify
  },
  data: {
    title: "",
    titleSlug: ""
  }
});

Usage

Just apply the name and the model name that you want to have the value of the slug

<div id="app">

<input type="text" v-model="title" class="form-control">

<suglify :slugify="title" :slug.sync="titleSlug">
        <input slot-scope="{inputBidding}" v-bind="inputBidding"
               type="text" class="form-control" placeholder="Slug ...">
</suglify>

 </div>

 <script>
 const app = new Vue({
    el: '#app',
    components: {
          VueSuglify
    },
    data: {
         title : '',
         titleSlug : ''
    },
});
</script>

The separator can be change by passing sep attribute by default is -

<suglify :slugify="title" :slug.sync="titleSlug" sep="---">
        <input slot-scope="{inputBidding}" v-bind="inputBidding"
               type="text" class="form-control" placeholder="Slug ...">
</suglify>

If You want the first letter to be UpperCase you can use lowerCase

<suglify :slugify="title" :slug.sync="titleSlug" :lowerCase="false">
        <input slot-scope="{inputBidding}" v-bind="inputBidding"
               type="text" class="form-control" placeholder="Slug ...">
</suglify>

Limit the number letters using limit by default is 100

<suglify :slugify="title" :slug.sync="titleSlug" :limit="30">
        <input slot-scope="{inputBidding}" v-bind="inputBidding"
               type="text" class="form-control" placeholder="Slug ...">
</suglify>

You can now pass object named extras where you replace a letter with something of your choice

In this example we remplace letter s with letter Suglify

<suglify :slugify="title" :slug.sync="titleSlug" :extras="{'s' : 'Suglify'}">
        <input slot-scope="{inputBidding}" v-bind="inputBidding"
               type="text" class="form-control" placeholder="Slug ...">
</suglify>

Contributing

You are more than welcome to contribute to this repo with anything you think is useful. fixes are more than welcome.

vuejs-suglify's People

Contributors

simoebenhida avatar

Stargazers

Gaston Besada avatar Andrés Carrillo Herrera avatar Murod avatar Bayram Ali avatar Onofre Souza avatar AXeL avatar  avatar Wasan Wangarch avatar Peet Stander avatar  avatar Alexey avatar Adam avatar Daniel Blendea avatar Ferri Sutanto avatar Alexander Sokolov avatar   Victor avatar CHEWTOYS avatar Dan Alvidrez avatar ik5 avatar Mostafa Kamal avatar  avatar ADIL  avatar

Watchers

James Cloos avatar  avatar

vuejs-suglify's Issues

Automatic installation if Vue has been added to the global scope.

// On plugin.js file
import Suglify from './Suglify.vue';

const VueSuglify = {
  install (Vue) {
    Vue.component('suglify', Suglify)
  }
}
// Automatic installation if Vue has been added to the global scope.
if (typeof window !== 'undefined' && window.Vue) {
  window.Vue.use(VueSuglify)
}

export default VueSuglify

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.