Run <if> value by ts_search:subst/2#311
Conversation
|
I first thought about adding a flag to enable the substitution (like with Another option would be to a new/alternative attribute beside the literal "value". The current solution feels the most natural too me though. What do you think, @nniclausse? |
|
ping @nniclausse |
|
maybe we can add a subst flag during the xml parsing, if we detect the %%xxx%% pattern ? if we don't do that, every use of an 'if' will call ts_search:subst even if we don't need substitutions. |
|
I like that idea! I was first thinking about I'll try to give this a shot. |
|
Can you take another look, @nniclausse? I'm not sure if this approach is sufficient. I'm simply peeking into the value and if I see |
|
Could you take another look, @nniclausse? |
| NewId = NewConf#config.curid, | ||
| ?LOGF("endif in session ~p as id ~p",[CurS#session.id,NewId+1],?INFO), | ||
| InitialAction = {ctrl_struct, {if_start, Rel, VarName, list_to_binary(Value) , NewId+1}}, | ||
| SubstitutionFlag = case string:str(Value, "%%") of |
There was a problem hiding this comment.
we should use re:run(Value, "%%.+%%") instead if think
There was a problem hiding this comment.
Okay. I thought string:str because that's recommended for performance reasons, but since we are only parsing the configuration, that should not be a issue to begin with.
I'll change this.
Do you have anything else on the new approach?
This PR will run the
valueof<if>byts_search:subst/2to make it work with variables as well.For example, if you need to compare a variable against another variable that you've extracted from a previous request, you can now do that.
Example:
Fixes #168