Skip to content

Instantly share code, notes, and snippets.

@fixmysync
Last active November 29, 2016 22:16
Show Gist options
  • Save fixmysync/526a9f3a0a7221408fa193987b18cc84 to your computer and use it in GitHub Desktop.
Save fixmysync/526a9f3a0a7221408fa193987b18cc84 to your computer and use it in GitHub Desktop.
{% comment %} inline BG Image {% endcomment %}
<div style="background-image: url({{ 'photoname.jpg' | asset_img_url: 'master' }});"></div>
{% comment %} Camelcase page ID. ex. id="aboutUs" {% endcomment %}
{% assign strings = page_title | handle | split: '-' %}
{% for string in strings %}{% if forloop.first == true %}{{ string }}{% else %}{{ string | capitalize }}{% endif %}{% endfor %}
{% comment %} Spit Out Object Properties {% endcomment %}
{{ object | json }}
{% comment %} convert dates to number of seconds since 1970-01-01 00:00:00 UTC {% endcomment %}
{% assign dateStart = product.created_at | date: '%s' %}
{% assign nowTimestamp = 'now' | date: '%s' %}
{% comment %} difference in seconds {% endcomment %}
{% assign diffSeconds = nowTimestamp | minus: dateStart %}
{% comment %} difference in days {% endcomment %}
{% assign diffDays = diffSeconds | divided_by: 3600 | divided_by: 24 %}
<p>difference in days = {{ diffDays }}</p>
{% comment %} Subtract Birthday from Today to get Age in "Years Old" {% endcomment %}
{% assign birthday = 11 %}
{% assign month = 03 %}
{% assign birthyear = 1977 %}
{% assign ms_per_year = 31536000 %}
{% assign todayInMS = 'now' | date: '%s' %}
{% if birthyear and month and birthday %}
{% assign birthDate = birthyear | append: '-' | append: month | append: '-' | append: birthday | date: '%Y-%m-%d' %}
{% assign birthDateInMS = birthDate | date: '%s' %}
{% assign ageInYears = todayInMS | minus: birthDateInMS | divided_by: ms_per_year %}
{% endif %}
The person is: {{ ageInYears }} Years Old
{% comment %} assign current_url {% endcomment %}
{% assign current_url = '' %}
{% case template %}
{% when 'page' %}
{% assign current_url = page.url %}
{% when 'blog' %}
{% assign current_url = blog.url %}
{% when 'article' %}
{% assign current_url = blog.url %}
{% when 'collection' %}
{% assign current_url = collection.url %}
{% when 'product' %}
{% assign current_url = product.url %}
{% endcase %}
{% comment %} Development Helpers: See the template and page handle {% endcomment %}
<div style="position: fixed; bottom: 0; right: 0; max-width: 50%; background: rgba(0,0,0,0.5);">
<p style="display: inline-block; background: yellow; border: 1px solid #000000; padding: 1em; font-weight: 700;">Current template: templates/{{ template }}.liquid</p>
<p style="display: inline-block; background: #7FFF00; border: 1px solid #000000; padding: 1em; font-weight: 700;">Handle: {{ page.handle }}</p>
</div>
{% comment %}
*******************************************************
*******************************************************
TODO: NOTICEABLE COMMENT BLOCK
*******************************************************
*******************************************************
{% endcomment %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment