I would avoid using an embed in that case.
An embedded template is the second to last thing to be processed, see ExpressionEngine's Parse Order courtesy Lowe.
If you want to re-use that code you can use it in a snippet (and use an add-on like Brian Litzinger's Snippet Sync to manage snippets as files if that's what's been preventing you from using snippets).
so e.g. your {snippet:getgenderurltitle}
's contents could be like (replace embed with {stash:get...}
):
{exp:low_replace find="\r|\n|\t" replace="" regex="yes"}
{exp:channel:entries
channel="genders"
disable="categories|category_fields|member_data|pagination"
dynamic="no"
orderby="entry_id"
sort="asc"
}
{if '{exp:stash:get name="chosen_gender_id"}' == entry_id}
{url_title}
{/if}
{/exp:channel:entries}
{/exp:low_replace}
and stash that, e.g.
{exp:stash:set name="get_gender_url_title" parse_tags="yes" trim="yes"}
{snippet:getgenderurltitle}
{/exp:stash:set}
Then for your conditional you can use Switchee:
{exp:switchee parse="inward" variable="stash:get_gender_url_title"}
{case value="male"}
{!-- do nothing --}
{/case}
{case default="Yes"}
{!-- do something --}
{/case}
{/exp:switchee}
channel:form comment EDIT
I'm not really familiar with safecracker/channel:form. Can you not use the Query Module for that? E.g.
{exp:query sql="SELECT url_title AS gender_url_title FROM exp_channel_titles WHERE url_title != 'male' AND entry_id = '{exp:stash:chosen_gender_id}'"}
{gender_url_title}
{/exp:query}
you may not be able to use the no results conditional, in that case stash the results/lack thereof (with parse tags & trim) and use {exp:stash:not_empty ...}
No SQL comment EDIT
You can just stick to embedded templates, then. Except instead of running your conditional in the same template, do it in another one saving any variables you need via stash so you can re-use them in the embedded template.
E.g. your initial embedded template (taking out low replace for stash with trim)
{exp:stash:set name="gender_url_title" parse_tags="yes" parse_conditionals="yes" trim="yes"}
{exp:channel:entries
channel="genders"
entry_id="{embed:chosen_gender_id}"
limit="1"
disable="categories|category_fields|member_data|pagination"
dynamic="no"
orderby="entry_id"
sort="asc"
}
{url_title}
{/exp:channel:entries}
{/exp:stash:set}
Then you ought to be able to run your conditional in another embedded template right afterwards (this would be the contents of that embedded template) (untested but it ought to work):
{if {exp:stash:not_empty name='gender_url_title'}
{if "{exp:stash:get name='gender_url_title'}" != "male"}
{!-- run code here --}
...{exp:stash:get name="saved_channel_form_variable..."}...
{/if}
{/if}