Craft equivalent to EE snippets for use in templates?
Craft uses Twig, and Twig uses macros for reusing snippets of code within templates.

In your macro file (for instance, macro/userMacro.html), you can create a macro:

{% macro hairColor(user) %}
    &lt;span class="hair-{{ user.hairColor }}"&gt;{{ user.hairColor }}&lt;/span&gt;
{% endmacro %}


Then, in any other file (or in your main _layout template, for that matter), you can import and use this macro:

{% import "macro/userMacro" as userMacro %}

{% for user in craft.users %}
    {{ userMacro.hairColor }}
{% endfor %}


Place your import-tag at the top of your _layout file, and you will be able to use it in every template that extends it (or is included by it).