Popular JavaScript recipes tagged "snippet"http://code.activestate.com/recipes/langs/javascript/tags/snippet/2011-05-25T20:52:56-07:00ActiveState Code RecipesA Template for Crash-Resistant Toggle-Macros (JavaScript) 2010-10-07T00:51:42-07:00Eric Promislowhttp://code.activestate.com/recipes/users/4166930/http://code.activestate.com/recipes/577418-a-template-for-crash-resistant-toggle-macros/ <p style="color: grey"> JavaScript recipe 577418 by <a href="/recipes/users/4166930/">Eric Promislow</a> (<a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/snippet/">snippet</a>, <a href="/recipes/tags/template/">template</a>). </p> <p>If you've followed my postings here lately (<a href="http://code.activestate.com/recipes/users/4166930/" rel="nofollow">http://code.activestate.com/recipes/users/4166930/</a>), you'll see that I've been playing with what I call "toggle macros", macros that toggle a state on and off, with different behaviors for each state. Unfortunately I found that it was easy to get Komodo to crash on shutdown. Meanwhile I wanted to build a framework to make it easier to build these.</p> <p>This recipe accomplishes both. It looks like putting a listener on a view object can trigger this crash, but so can storing a method on a view object, even with a unique name. So while I wanted to use the "view.view_closing" event, I can't, and I notice no other core Komodo code is. The template instead uses a global hash, ko.extensions.togglers, to store the code objects. And now I'm not getting a crash.</p> Komodo Snippet Wrapper macro (JavaScript) 2011-05-25T20:52:56-07:00Jeff Griffithshttp://code.activestate.com/recipes/users/835605/http://code.activestate.com/recipes/577168-komodo-snippet-wrapper-macro/ <p style="color: grey"> JavaScript recipe 577168 by <a href="/recipes/users/835605/">Jeff Griffiths</a> (<a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/snippet/">snippet</a>, <a href="/recipes/tags/toolbox/">toolbox</a>). </p> <p>A simple Macro that wraps the current selection in a code block supplied by the requested snippet.</p>