You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -164,6 +172,32 @@ If `$$$ARGS` does match nodes, then the replacement regular expression will repl
164
172
This method is invented by [Surma](https://surma.dev/) in a [tweet](https://twitter.com/DasSurma/status/1706086320051794217), so the useful trick is named after him.
165
173
:::
166
174
175
+
## String Style Transformations
176
+
177
+
To simplify the syntax of transformations, ast-grep 0.38.3+ supports a new string style transformation syntax. This allows us to write transformations in a more concise and readable way.
178
+
179
+
The string style transformation syntax is similar to the CSS function call syntax
180
+
181
+
```yaml
182
+
# illustration of string style transformation syntax
The transformation name is followed by parentheses containing the arguments. The first argument is always the source meta-variable, and the rest are the transformation options in the form of key-value pairs.
187
+
188
+
For example, the transformation examples above can be written as:
The string style transformation syntax is only available in ast-grep 0.38.3 and later versions. If you are using an older version, please use the original object style syntax.
199
+
:::
200
+
167
201
## Even More Advanced Transformations
168
202
169
203
We can use rewriters in the [`rewrite`](/guide/rewrite/rewriter.html) transformation to apply dynamic transformations to the AST. We will cover it in next section.
@@ -295,7 +303,7 @@ Extra information for the rule. This section can include custom data for externa
295
303
296
304
ast-grep will output `metadata` with matches in [`--json`](/reference/cli/scan.html#json-style) mode if [`--include-metadata`](/reference/cli/scan.html#include-metadata) is on.
0 commit comments