Oddity in PHP Snippets


Hey folks,

I recently switched to the fabulous Atom and came across a bug while porting my snippets manually.

I saw this topic: PHP Snippets not working
Followed the hints but there lays an oddity while working with different snippets.
I think it may be related to containing html tags within which the php blocks and code are placed.

For instance, this works:

  'print constant':
    'prefix': 'printcons'
    'body': '<?php print $2 ; ?>'

and this doesn’t:

  'wp pingback':
    'prefix': 'pingback'
    'body': '<?php bloginfo("pingback_url"); ?>'

I would be very much grateful if you can guide me to overcome this issue.
Many thanks in advance.


Do you have both of those full blocks in your snippets.cson file? If so, see this FAQ:


Thanks for your response but it didn’t help at all!


So what does your snippets.cson contain in it exactly?


It has got rather long but here’s a glimpse:


If you take a look at the FAQ I linked above, CSON is analogous to JSON. This means that only the last .text.html.php section is the one that is used … it overwrites the previous ones. So in your example, you would need to change it to:

  'wp get sidebar':
    'prefix': 'wpgs'
    'body': '<?php get_sidebar(); ?>'
  'wp get header':
    'prefix': 'wpgh'
    'body': '<?php get_header(); ?>'
  'wp get header':
    'prefix': 'wpgf'
    'body': '<?php get_footer(); ?>'

  'wp style.css':
    'prefix': 'wpstylecss'
    'body': """


Oh thanks. It’s working just fine.
That was quite subtle btw.

A question, so from here on out do I have to insert all of my html/php snippets below this block without writing another .text.html.php ?


Yes, that’s correct.