View Source Uniform.Modifiers (Uniform v0.6.0)
Utilities for building code transformations with
Uniform.Blueprint.modify/2
.
Link to this section Summary
Functions
Apply Eject Fences to extra languages with this function.
Link to this section Functions
@spec eject_fences( String.t(), Uniform.App.t(), prefix :: String.t(), suffix :: String.t() | nil ) :: String.t()
Apply Eject Fences to extra languages with this function.
Uniform already applies Eject Fences to Elixir (.ex/.exs
) and JavaScript
(.js/.jsx/.ts/.tsx
) files automatically.
use Uniform.Blueprint
imports eject_fences
.
examples
Examples
# code fences for SQL files
modify ~r/\.sql$/, &eject_fences(&1, &2, "--")
# code fences for Rust files
modify ~r/\.rs$/, fn file, app ->
eject_fences(file, app, "//")
end
Note that the prefix
and suffix
are placed directly into a Regex
using
Regex.compile!/2
. Therefore, if the prefix
and suffix
include special
Regex characters such as *
, they must be escaped appropriately.
For example, the following would process CSS /* comments */
.
# code fences for CSS files
modify ~r/\.css$/, fn file, app ->
eject_fences(file, app, "/\\*", "\\*/")
end