diff --git a/splinext/pokedex/helpers.py b/splinext/pokedex/helpers.py index 2f9fbd35..fe35cc6a 100644 --- a/splinext/pokedex/helpers.py +++ b/splinext/pokedex/helpers.py @@ -622,7 +622,10 @@ def scale_sizes(size_dict, dimensions=1): return scaled_sizes -def apply_pokemon_template(template, pokemon, _=_): +def _no_icon(pokemon): + return u"" + +def apply_pokemon_template(template, pokemon, get_icon=_no_icon, _=_): u"""`template` should be a string.Template object. Uses safe_substitute to inject some fields from the Pokémon into the @@ -633,7 +636,7 @@ def apply_pokemon_template(template, pokemon, _=_): """ d = dict( - icon=pokemon_form_image(pokemon.default_form, prefix=u'icons'), + icon=get_icon(pokemon), id=pokemon.species.id, name=pokemon.default_form.name, diff --git a/splinext/pokedex/templates/pokedex/search/pokemon.mako b/splinext/pokedex/templates/pokedex/search/pokemon.mako index 4910e3cc..37593d26 100644 --- a/splinext/pokedex/templates/pokedex/search/pokemon.mako +++ b/splinext/pokedex/templates/pokedex/search/pokemon.mako @@ -17,6 +17,12 @@

${_(u"Start over")}

+<% +# Callback for apply_pokemon_template +def get_icon(pokemon): + return dexlib.pokemon_form_image(pokemon.default_form, prefix=u'icons') +%> + ### RESULTS ### ## Four possibilities here: the form wasn't submitted, the form was submitted ## but was bogus, the form was submitted and there are no results, or the form @@ -132,7 +138,7 @@ ${getattr(self, 'col_' + column)()} ## Plain bulleted list with a Template. @@ -141,7 +147,7 @@ ${getattr(self, 'col_' + column)()} ## friendly to clipboards.
% for result in c.results: -${dexlib.pokemon_link(result, h.pokedex.apply_pokemon_template(c.display_template, result))}
+${dexlib.pokemon_link(result, h.pokedex.apply_pokemon_template(c.display_template, result, get_icon=get_icon))}
% endfor
@@ -366,7 +372,7 @@ ${h.form(url.current(), method='GET')} <%! from string import Template %>\ <% template = Template(pattern) %>\
${pattern}
-
${h.pokedex.apply_pokemon_template(template, c.eevee)}
+
${h.pokedex.apply_pokemon_template(template, c.eevee, get_icon=get_icon)}
% endfor