DailyJS

ngKookies, preCode.js

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

HTML cookies angularjs dm

ngKookies, preCode.js

Posted by Alex R. Young on .
Featured

HTML cookies angularjs dm

ngKookies, preCode.js

Posted by Alex R. Young on .

ngKookies

ngKookies (GitHub: voronianski/ngKookies, License: MIT, npm: ngkookies) by Dmitri Voronianski is a replacement for the Angular $cookieStore provider. It's a port of jquery-cookie that helps work around angular.js issue 950.

After loading it, you can set cookies with $kookies.set('name', 'value') and read them with $kookies.get. You can also delete cookies with $kookies.remove.

Each method accepts an options object that can include the path and expires arguments. You can also store JSON objects as cookies with $kookiesProvider.config.json = true.

preCode.js

Have you ever written a blog engine or CMS that has to display source code? If so you've probably run into the issue where human-readable HTML doesn't work well with pre elements if initial indentation is included.

preCode.js (License: MIT) Leon Sorokin is a small script that finds <pre><code> blocks and strips the leading and proceeding whitespace, so syntax highlighters should be able to display code properly.

It's written using the standard DOM API, so it shouldn't need any dependencies. It'll also fix whitespace in textarea as well.