module
AssetPipeline::Platform
Overview
Platform-gate helpers for application code.
Library code (anything under src/ui/views/, src/ui/renderers/)
continues to use raw {% if flag?(:ios) %} blocks because it sits
below the abstraction surface. Application code should reach for
AssetPipeline::Platform.requires(:ios) { ... } so it does not have
to learn Crystal macro syntax to express "this block needs -Dios."
Defined in:
asset_pipeline/platform.crMacro Summary
-
has?(platform_flag)
Compile-time platform predicate.
-
requires(platform_flag, &block)
Compile-time platform gate.
Macro Detail
Compile-time platform predicate. Use in {% if Platform.has?(:ios) %}
contexts when the macro form above is more verbose than needed.
Compile-time platform gate. Use in app code to assert that a block
is only entered on a specific platform target. If the build does
not have the matching -D flag, the macro raises a compile error
naming the missing flag.
Example: AssetPipeline::Platform.requires(:ios) do trigger_haptic end
On non-iOS builds this raises: "AssetPipeline::Platform.requires(:ios) - this code path needs -Dios."