adobe / adobe/helix-shared

[indexer] support conditional expressions

Open
#1,096 6 comments 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
JavaScript
Stars
15
Forks
16
Avg merge
23h 18m
Merged PRs (30d)
14

Description

The indexer currently doesn't support conditionals, e.g.:

```
select: a, img
values: |
el.tagName === 'A'
? match(attribute(el, 'href'), 'pattern')
: match(attribute(el, 'src'), 'pattern')
```

which is supposed to act differently, depending on whether the element selected is an `a` or an `img` tag.

As a matter of fact, already the binary expression `el.tagName === 'A'` isn't supported, and the underlying problem goes deeper: the `select: a, img` expression will return an **array** of matching elements, and so every subsequent expression - binary and conditional - should also work on an array.

Contributor guide

Open the contributing guide

Research direction

Start at the indexer expression evaluation entry point and trace how select, binary, and conditional expressions are handled. Reproduce the example with `select: a, img`, then verify that binary and conditional expressions work when the selection returns an array and produce the expected href or src match.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.