Skip to content

Instantly share code, notes, and snippets.

@molovo
Created October 9, 2013 10:37
Show Gist options
  • Save molovo/6899304 to your computer and use it in GitHub Desktop.
Save molovo/6899304 to your computer and use it in GitHub Desktop.
A small sublime snippet set for anchor CMS. Save the file in /Users/<username>/Library/Application Support/Sublime Text 2/Packages/User. Tweet @molovo for further requests :)
<snippet>
<content><![CDATA[
<?php if(has_posts()): ?>
<ul>
<?php while(posts()): ?>
<li>
<article>
<h1>
<a href="<?php echo article_url(); ?>" title="<?php echo article_title(); ?>">
<?php echo article_title(); ?>
</a>
</h1>
<div>
<?php echo article_markdown(); ?>
${1:<!-- Enter any additional text to appear within the article here. -->}
</div>
<footer>
${2:<!-- This footer will appear beneath each article. -->}
</footer>
</article>
</li>
<?php endwhile; ?>
</ul>
<?php if(has_pagination()): ?>
<nav>
<div>
<?php echo posts_prev(); ?>
<?php echo posts_next(); ?>
</div>
</nav>
<?php endif; ?>
<?php else: ?>
<!-- Return a message if no posts exist -->
<p>${0:Looks like you have some writing to do!}</p>
<?php endif; ?>
]]></content>
<tabTrigger>posts</tabTrigger>
</snippet>
<snippet>
<content><![CDATA[
<?php if(has_menu_items()): ?>
<nav>
<ul>
<?php while(menu_items()): ?>
<li>
<a href="<?php echo menu_url(); ?>" title="<?php echo menu_title(); ?>">
<?php echo menu_name(); ?>
</a>
</li>
<?php endwhile; ?>
</ul>
</nav>
<?php endif; ?>
]]></content>
<tabTrigger>menu</tabTrigger>
</snippet>
<snippet>
<content><![CDATA[
<?php if(has_categories()): ?>
<nav>
<ul>
<?php while(categories()): ?>
<li>
<a href="<?php echo category_url(); ?>" title="<?php echo category_title(); ?>">
<h3><?php echo category_title(); ?> - (<?php echo category_count(); ?>)</h3>
<p><?php echo category_description(); ?></p>
</a>
</li>
<?php endwhile; ?>
</ul>
</nav>
<?php endif; ?>
]]></content>
<tabTrigger>categories</tabTrigger>
</snippet>
<snippet>
<content><![CDATA[
<?php if(has_menu_items()): ?>
<?php while(menu_items()): ?>
<section>
<h1><?php echo menu_title(); ?></h1>
<?php echo parse(Page::slug(basename(menu_relative_url()))->content); ?>
</section>
<?php endwhile; ?>
<?php endif; ?>
]]></content>
<tabTrigger>page-sections</tabTrigger>
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment