🧰 ユーティリティ上級
tablerow タグのフォーマット規則
Prettier プラグイン内の tablerow タグの行折り返しテストケース。reversed、limit、offset などのオプション引数がある場合の自動フォーマット仕様を定義する。
用途
Liquid コードを自動整形するツール、または開発チームで Liquid の統一フォーマットルールを検証する際に参考となる。
設置場所
このファイルはテストケース集であり、直接ストアテーマに貼り付けるものではない。theme-tools の prettier-plugin-liquid を利用して、自作 tablerow タグのフォーマット検証に参考にする。
注意点
このコードは Prettier プラグインのテスト定義であり、実際の tablerow タグ使用時の動作検証ではない。printWidth 値(1 や 80)はコード整形の判定基準であり、実装時には自プロジェクトの Prettier 設定に合わせて調整する。tablerow タグの reversed、limit、offset パラメータは Liquid 仕様として実装されているため、これらの引数が有効か事前に公式リファレンスで確認すること。
コード
41 行 / liquidIt takes an element and a collection
{% tablerow element in collection %}{% endtablerow %}
It does not breaks on in collection
printWidth: 1
{% tablerow element in collection %}
{{ collection }}
{% endtablerow %}
It breaks on reversed
printWidth: 1
{% tablerow element in collection
reversed
%}
{{ element }}
{% endtablerow %}
It breaks on tag arguments
printWidth: 1
{% tablerow element in collection
limit: 10
offset: 10
%}
{{ element }}
{% endtablerow %}
It breaks on both reversed and tag argumentsc
printWidth: 1
{% tablerow element in collection
reversed
limit: 10
%}
{{ element }}
{% endtablerow %}
It only breaks if the printWidth is hit
printWidth: 80
{% tablerow element in collection reversed limit: 10 %}
{{ element }}
{% endtablerow %}
出典・ライセンス
- Source:
- Shopify/theme-tools/packages/prettier-plugin-liquid/src/test/liquid-tag-tablerow/fixed.liquid
- Repository:
- https://github.com/Shopify/theme-tools
- License:
- MIT
このコードは Shopify 著作の MIT ライセンスソースです。 原本の著作権は Shopify が保有します。日本語訳は ALSEL によるものです。
関連項目
🧰 ユーティリティ初級
コメント後の空白フォーマット
Liquid コメントタグの直後に改行や空白がある場合の正しいフォーマット例。prettier-plugin-liquid によるコード整形テストケース。
📁 theme-tools·MIT·6 行
🧰 ユーティリティ初級
Liquidコメントのフォーマット
Liquid のコメントタグ直後に改行がある場合の正しいフォーマット例。prettier-plugin-liquid による自動整形テストケース。
📁 theme-tools·MIT·6 行
🧰 ユーティリティ初級
セクション呼び出しの改行制御
{% sections %} タグの前後の空白制御(ホワイトスペース削除演算子 `{%-` と `-%}` の使い方)を示すサンプル。Prettier による Liquid コードフォーマットで改行が崩れないことを確認するテストケース。
📁 theme-tools·MIT·7 行
🧰 ユーティリティ初級
Prettier フォーマッタの HTML リスト整形テスト
Prettier Liquid プラグインが HTML のリスト要素(ul / ol)をどのように整形・改行するかをテストするサンプルコード。短い行は1行、長い行は複数行に自動で分割される動作を検証する。
📁 theme-tools·MIT·8 行
🧰 ユーティリティ上級
Vue.js属性のLiquid整形
Vue.js のディレクティブ(@click、:class など)を含む Liquid コードを Prettier で正しく整形するテストケース。spec 準拠の属性名を保持したまま、改行・インデント処理を行う。
📁 theme-tools·MIT·9 行
🧰 ユーティリティ上級
sections タグのフォーマット
Liquid の sections タグ構文と、Prettier によるフォーマット時の動作を示すテストファイル。タグ名の直前・直後の空白や改行が保持される仕様を確認するサンプル。
📁 theme-tools·MIT·9 行