jQuery Plugin

I whipped up a little Bacon Ipsum jQuery plugin that uses our API to generate some meaty goodness.  When you’re mocking up a design, now you can use this plugin in your HTML rather than static text.

You can reference the plugin from our server or download it and use it locally.
http://cdn.baconipsum.com/api/jquery-BaconIpsum.js

The easiest way to use it is just to call the method with no options.
$('#placeholder').BaconIpsum();

You can also pass in options.

$('#placeholder).BaconIpsum({ type:'all-meat', paras:5, start_with_lorem:false });
$('#placeholder).BaconIpsum({ type:'meat-and-filler', sentences:1, start_with_lorem:true });

  • type: either ‘all-meat’ or ‘meat-and-filler’
  • paras: number of paragraphs
  • sentences: number of sentences (this overrides paragraphs)
  • start_with_lorem: true or false to start the text with ‘Bacon ipsum dolor sit amet’
  • no_tags: true or false, pass true to not wrap the return value in <p> tags
  • set_value: sets the element value rather than appending

There’s a sample page on GitHub with some example code.

This entry was posted in Blog and tagged , , . Bookmark the permalink.

5 Responses to jQuery Plugin

  1. Runner says:

    Very nice! No more needing to copy and paste!

  2. Pingback: Bacon Ipsum jQuery Plugin - Pixel Library

  3. Paul says:

    This is really cool and has been fun to play around with, however I would like to suggest an enhancement.
    Could you change the name of the ‘start_with_lorem’ param name to ‘start_with_bacon’ and default it as ‘false’?

    In it’s current state, if you don’t pass the param.. it still always starts with “Bacon ipsum dolor amet…” or maybe this was intended to always start with bacon?
    If I pass in nothing or or only the param “start_with_lorem: false” I would expect that I get the same result of not starting with bacon either way. I just feel like the logic is a little off here.

  4. John says:

    The bacon Ipsum is cool, but having a cdn is awesome.
    Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *