Re: More standard template filters

2020-02-01 Thread Fran Hrženjak
A similar ticket from 6 years ago (with some more filters) was closed as a 
wontfix: https://code.djangoproject.com/ticket/22162
Unless there was a change in the phylosiphy, I don’t think this will be 
accepted either (I don’t have an opinion about whether it shouldbe, though 
leaning towards not).

As a side note, I think the `in` operator fills the function of the 
`contains` filter:
"testing" in myvar



On Saturday, 1 February 2020 17:28:03 UTC+1, keshav kumar wrote:
>
> So, can I create as a new feature and start working on it ?
>
> On Wednesday, 29 January 2020 22:36:09 UTC+5:30, Collin Anderson wrote:
>>
>> I think it would be helpful to have builtin startswith, endswith and 
>> contains filters.
>>
>> On Thursday, January 23, 2020 at 4:40:32 PM UTC-5, keshav kumar wrote:
>>>
>>> There are already filters which works on advance logic. for example :- 
>>> 'join'. So, is it not good to add filter for startswith, endswith and 
>>> contains as well? 
>>>
>>> On Friday, 5 April 2019 14:46:53 UTC+5:30, Adam Johnson wrote:

 FYI Jinja2 allows (most) python expressions, so this would Just 
 Work(TM):

 {{  myvar.startswith("x") }}

 Django Template Language has a lot of legacy that prevents this from 
 happening, afaiu it would not be possible to move to it.

 It's not hard to move your templates (asides from those extending 
 external packages like the admin) to Jinja2, since the syntax is very 
 similar and you can pop a Jinja2 backend in your TEMPLATES.



 On Fri, 5 Apr 2019 at 07:43, Curtis Maloney  
 wrote:

> On 4/5/19 3:06 AM, Collin Anderson wrote:
> > Hi All,
> > 
> > I use django templates a lot and I always wished there was a 
> > myvar|startswith:"teststring", myvar|endswith:"teststring" and a 
> > myvar|contains:"teststring" filter.
>
> It's almost like we need a syntax for calling methods with an 
> argument, 
> just like we can with filters.
>
> For example (bring on the sheds for bikes!)
>
>  {{ myvar.startswith<"teststring" }}
>
> > I instead do stuff like myvar|slice:":10" == "teststring" which is a 
> > total hack.
> > 
> > Is this something that could be simple and common enough to add to 
> > django as batteries-included built-in?
>
> Alternatively, I recall some time in the past I may have written a 
> "strings" template filter library simply to provide string methods as 
> filters...
>
> --
> Curtis
>
> -- 
> You received this message because you are subscribed to the Google 
> Groups "Django developers  (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send 
> an email to django-d...@googlegroups.com.
> To post to this group, send email to django-d...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/a2b323bc-9f60-f4c9-6074-4d103bd6f930%40tinbrain.net
> .
> For more options, visit https://groups.google.com/d/optout.
>


 -- 
 Adam

>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/bf1c7e37-fbc6-46d1-8c12-fb4f42977bc4%40googlegroups.com.


Re: More standard template filters

2020-02-01 Thread keshav kumar
So, can I create as a new feature and start working on it ?

On Wednesday, 29 January 2020 22:36:09 UTC+5:30, Collin Anderson wrote:
>
> I think it would be helpful to have builtin startswith, endswith and 
> contains filters.
>
> On Thursday, January 23, 2020 at 4:40:32 PM UTC-5, keshav kumar wrote:
>>
>> There are already filters which works on advance logic. for example :- 
>> 'join'. So, is it not good to add filter for startswith, endswith and 
>> contains as well? 
>>
>> On Friday, 5 April 2019 14:46:53 UTC+5:30, Adam Johnson wrote:
>>>
>>> FYI Jinja2 allows (most) python expressions, so this would Just Work(TM):
>>>
>>> {{  myvar.startswith("x") }}
>>>
>>> Django Template Language has a lot of legacy that prevents this from 
>>> happening, afaiu it would not be possible to move to it.
>>>
>>> It's not hard to move your templates (asides from those extending 
>>> external packages like the admin) to Jinja2, since the syntax is very 
>>> similar and you can pop a Jinja2 backend in your TEMPLATES.
>>>
>>>
>>>
>>> On Fri, 5 Apr 2019 at 07:43, Curtis Maloney  wrote:
>>>
 On 4/5/19 3:06 AM, Collin Anderson wrote:
 > Hi All,
 > 
 > I use django templates a lot and I always wished there was a 
 > myvar|startswith:"teststring", myvar|endswith:"teststring" and a 
 > myvar|contains:"teststring" filter.

 It's almost like we need a syntax for calling methods with an argument, 
 just like we can with filters.

 For example (bring on the sheds for bikes!)

  {{ myvar.startswith<"teststring" }}

 > I instead do stuff like myvar|slice:":10" == "teststring" which is a 
 > total hack.
 > 
 > Is this something that could be simple and common enough to add to 
 > django as batteries-included built-in?

 Alternatively, I recall some time in the past I may have written a 
 "strings" template filter library simply to provide string methods as 
 filters...

 --
 Curtis

 -- 
 You received this message because you are subscribed to the Google 
 Groups "Django developers  (Contributions to Django itself)" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to django-d...@googlegroups.com.
 To post to this group, send email to django-d...@googlegroups.com.
 Visit this group at https://groups.google.com/group/django-developers.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-developers/a2b323bc-9f60-f4c9-6074-4d103bd6f930%40tinbrain.net
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>
>>> -- 
>>> Adam
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/d49e01f7-856d-4b26-9db0-df18aa3b6b52%40googlegroups.com.


Re: More standard template filters

2020-01-29 Thread Collin Anderson
I think it would be helpful to have builtin startswith, endswith and 
contains filters.

On Thursday, January 23, 2020 at 4:40:32 PM UTC-5, keshav kumar wrote:
>
> There are already filters which works on advance logic. for example :- 
> 'join'. So, is it not good to add filter for startswith, endswith and 
> contains as well? 
>
> On Friday, 5 April 2019 14:46:53 UTC+5:30, Adam Johnson wrote:
>>
>> FYI Jinja2 allows (most) python expressions, so this would Just Work(TM):
>>
>> {{  myvar.startswith("x") }}
>>
>> Django Template Language has a lot of legacy that prevents this from 
>> happening, afaiu it would not be possible to move to it.
>>
>> It's not hard to move your templates (asides from those extending 
>> external packages like the admin) to Jinja2, since the syntax is very 
>> similar and you can pop a Jinja2 backend in your TEMPLATES.
>>
>>
>>
>> On Fri, 5 Apr 2019 at 07:43, Curtis Maloney  wrote:
>>
>>> On 4/5/19 3:06 AM, Collin Anderson wrote:
>>> > Hi All,
>>> > 
>>> > I use django templates a lot and I always wished there was a 
>>> > myvar|startswith:"teststring", myvar|endswith:"teststring" and a 
>>> > myvar|contains:"teststring" filter.
>>>
>>> It's almost like we need a syntax for calling methods with an argument, 
>>> just like we can with filters.
>>>
>>> For example (bring on the sheds for bikes!)
>>>
>>>  {{ myvar.startswith<"teststring" }}
>>>
>>> > I instead do stuff like myvar|slice:":10" == "teststring" which is a 
>>> > total hack.
>>> > 
>>> > Is this something that could be simple and common enough to add to 
>>> > django as batteries-included built-in?
>>>
>>> Alternatively, I recall some time in the past I may have written a 
>>> "strings" template filter library simply to provide string methods as 
>>> filters...
>>>
>>> --
>>> Curtis
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django developers  (Contributions to Django itself)" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-d...@googlegroups.com.
>>> To post to this group, send email to django-d...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-developers.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-developers/a2b323bc-9f60-f4c9-6074-4d103bd6f930%40tinbrain.net
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> -- 
>> Adam
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/567c54a9-2496-4619-9d6c-59758921c8ce%40googlegroups.com.


Re: More standard template filters

2020-01-23 Thread keshav kumar
There are already filters which works on advance logic. for example :- 
'join'. So, is it not good to add filter for startswith, endswith and 
contains as well? 

On Friday, 5 April 2019 14:46:53 UTC+5:30, Adam Johnson wrote:
>
> FYI Jinja2 allows (most) python expressions, so this would Just Work(TM):
>
> {{  myvar.startswith("x") }}
>
> Django Template Language has a lot of legacy that prevents this from 
> happening, afaiu it would not be possible to move to it.
>
> It's not hard to move your templates (asides from those extending external 
> packages like the admin) to Jinja2, since the syntax is very similar and 
> you can pop a Jinja2 backend in your TEMPLATES.
>
>
>
> On Fri, 5 Apr 2019 at 07:43, Curtis Maloney  > wrote:
>
>> On 4/5/19 3:06 AM, Collin Anderson wrote:
>> > Hi All,
>> > 
>> > I use django templates a lot and I always wished there was a 
>> > myvar|startswith:"teststring", myvar|endswith:"teststring" and a 
>> > myvar|contains:"teststring" filter.
>>
>> It's almost like we need a syntax for calling methods with an argument, 
>> just like we can with filters.
>>
>> For example (bring on the sheds for bikes!)
>>
>>  {{ myvar.startswith<"teststring" }}
>>
>> > I instead do stuff like myvar|slice:":10" == "teststring" which is a 
>> > total hack.
>> > 
>> > Is this something that could be simple and common enough to add to 
>> > django as batteries-included built-in?
>>
>> Alternatively, I recall some time in the past I may have written a 
>> "strings" template filter library simply to provide string methods as 
>> filters...
>>
>> --
>> Curtis
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django developers  (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-d...@googlegroups.com .
>> To post to this group, send email to django-d...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-developers.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-developers/a2b323bc-9f60-f4c9-6074-4d103bd6f930%40tinbrain.net
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> Adam
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/b447536a-a5e8-47d9-b06f-75f44ef87abc%40googlegroups.com.


Re: More standard template filters

2019-04-05 Thread Curtis Maloney

On 4/5/19 8:16 PM, Adam Johnson wrote:

FYI Jinja2 allows (most) python expressions, so this would Just Work(TM):

{{  myvar.startswith("x") }}

Django Template Language has a lot of legacy that prevents this from 
happening, afaiu it would not be possible to move to it.


For "legacy" read "philosophical choices" :)

--
Curtis

--
You received this message because you are subscribed to the Google Groups "Django 
developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/496aa5dc-058c-4126-164a-e421cd20162a%40tinbrain.net.
For more options, visit https://groups.google.com/d/optout.


Re: More standard template filters

2019-04-05 Thread Adam Johnson
FYI Jinja2 allows (most) python expressions, so this would Just Work(TM):

{{  myvar.startswith("x") }}

Django Template Language has a lot of legacy that prevents this from
happening, afaiu it would not be possible to move to it.

It's not hard to move your templates (asides from those extending external
packages like the admin) to Jinja2, since the syntax is very similar and
you can pop a Jinja2 backend in your TEMPLATES.



On Fri, 5 Apr 2019 at 07:43, Curtis Maloney  wrote:

> On 4/5/19 3:06 AM, Collin Anderson wrote:
> > Hi All,
> >
> > I use django templates a lot and I always wished there was a
> > myvar|startswith:"teststring", myvar|endswith:"teststring" and a
> > myvar|contains:"teststring" filter.
>
> It's almost like we need a syntax for calling methods with an argument,
> just like we can with filters.
>
> For example (bring on the sheds for bikes!)
>
>  {{ myvar.startswith<"teststring" }}
>
> > I instead do stuff like myvar|slice:":10" == "teststring" which is a
> > total hack.
> >
> > Is this something that could be simple and common enough to add to
> > django as batteries-included built-in?
>
> Alternatively, I recall some time in the past I may have written a
> "strings" template filter library simply to provide string methods as
> filters...
>
> --
> Curtis
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers  (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/a2b323bc-9f60-f4c9-6074-4d103bd6f930%40tinbrain.net
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM009Hh5VbtPVc_96iJmoJaDJE_K-pwbYAqo4%2BQcDeVraw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: More standard template filters

2019-04-05 Thread Curtis Maloney

On 4/5/19 3:06 AM, Collin Anderson wrote:

Hi All,

I use django templates a lot and I always wished there was a 
myvar|startswith:"teststring", myvar|endswith:"teststring" and a 
myvar|contains:"teststring" filter.


It's almost like we need a syntax for calling methods with an argument, 
just like we can with filters.


For example (bring on the sheds for bikes!)

{{ myvar.startswith<"teststring" }}

I instead do stuff like myvar|slice:":10" == "teststring" which is a 
total hack.


Is this something that could be simple and common enough to add to 
django as batteries-included built-in?


Alternatively, I recall some time in the past I may have written a 
"strings" template filter library simply to provide string methods as 
filters...


--
Curtis

--
You received this message because you are subscribed to the Google Groups "Django 
developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/a2b323bc-9f60-f4c9-6074-4d103bd6f930%40tinbrain.net.
For more options, visit https://groups.google.com/d/optout.


More standard template filters

2019-04-04 Thread Collin Anderson
Hi All,

I use django templates a lot and I always wished there was a 
myvar|startswith:"teststring", myvar|endswith:"teststring" and a 
myvar|contains:"teststring" filter.

I instead do stuff like myvar|slice:":10" == "teststring" which is a total 
hack.

Is this something that could be simple and common enough to add to django 
as batteries-included built-in?

Thanks,
Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/4d465a4c-6d8c-498e-8310-d03dce5338ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.