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.cr

Macro Summary

Macro Detail

macro has?(platform_flag) #

Compile-time platform predicate. Use in {% if Platform.has?(:ios) %} contexts when the macro form above is more verbose than needed.


[View source]
macro requires(platform_flag, &block) #

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."


[View source]