Remove macros
This commit is contained in:
parent
659ec5cea5
commit
e6a8434ff2
|
|
@ -10,5 +10,14 @@ class FoobarExtension(Extension):
|
|||
|
||||
@pass_context
|
||||
def get_pyproject(self, context, setting):
|
||||
pyproject = context.get("cookiecutter", {})
|
||||
return f"Hello, {setting}! (pyproject: {pyproject})"
|
||||
pyproject = context.get("cookiecutter", {}).get("pyproject", {})
|
||||
|
||||
if not setting:
|
||||
return pyproject
|
||||
|
||||
d = pyproject
|
||||
for k in setting.split("."):
|
||||
d = d.get(k)
|
||||
if d is None:
|
||||
return None
|
||||
return d
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
{# _macros.jinja2 #}
|
||||
|
||||
{% macro get_value(dict, path) %}
|
||||
{# Split the path into keys #}
|
||||
{% set keys = path.split('.') %}
|
||||
{% if keys and dict is mapping and keys[0] in dict %}
|
||||
{% set next_value = dict[keys[0]] %}
|
||||
{% if keys | length == 1 %}
|
||||
{{ next_value }}
|
||||
{% else %}
|
||||
{{ get_value(next_value, keys[1:] | join('.')) }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ "" }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro get_config_platform(package_platform) %}
|
||||
{% if package_platform == "Darwin" %}
|
||||
macos
|
||||
{% elif package_platform == "Windows" %}
|
||||
windows
|
||||
{% elif package_platform == "Linux" %}
|
||||
linux
|
||||
{% elif package_platform == "iOS" %}
|
||||
ios
|
||||
{% elif package_platform == "Android" %}
|
||||
android
|
||||
{% else %}
|
||||
web
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
{% import "_macros.jinja2" as macros %}
|
||||
plugins {
|
||||
id "com.android.application"
|
||||
id "kotlin-android"
|
||||
|
|
@ -50,8 +49,8 @@ android {
|
|||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
|
||||
{% set min_sdk_version = macros.get_value(cookiecutter.pyproject, "tool.flet.android.min_sdk_version") | trim %}
|
||||
{% set target_sdk_version = macros.get_value(cookiecutter.pyproject, "tool.flet.android.target_sdk_version") | trim %}
|
||||
{% set min_sdk_version = get_pyproject("tool.flet.android.min_sdk_version") %}
|
||||
{% set target_sdk_version = get_pyproject("tool.flet.android.target_sdk_version") %}
|
||||
|
||||
defaultConfig {
|
||||
applicationId "{{ cookiecutter.org_name_2 }}.{{ cookiecutter.package_name }}"
|
||||
|
|
|
|||
|
|
@ -15,20 +15,14 @@ import 'package:window_manager/window_manager.dart';
|
|||
import "python.dart";
|
||||
|
||||
/*
|
||||
{% import "_macros.jinja2" as macros %}
|
||||
{% set config_platform = macros.get_config_platform(cookiecutter.options.package_platform) | trim %}
|
||||
{% set splash_screen = (macros.get_value(cookiecutter.pyproject, "tool.flet." ~ config_platform ~ ".loading_screen") | trim)
|
||||
or (macros.get_value(cookiecutter.pyproject, "tool.flet.loading_screen") | trim)
|
||||
or "False" %}
|
||||
{% set splash_screen_text = (macros.get_value(cookiecutter.pyproject, "tool.flet." ~ config_platform ~ ".loading_screen_text") | trim)
|
||||
or (macros.get_value(cookiecutter.pyproject, "tool.flet.loading_screen_text") | trim) %}
|
||||
{% set splash_screen = get_pyproject("tool.flet." ~ cookiecutter.options.config_platform ~ ".loading_screen")
|
||||
or get_pyproject("tool.flet.loading_screen")
|
||||
or False %}
|
||||
{% set splash_screen_text = get_pyproject("tool.flet." ~ cookiecutter.options.config_platform ~ ".loading_screen_text")
|
||||
or get_pyproject("tool.flet.loading_screen_text") %}
|
||||
|
||||
splash_screen: {{ splash_screen }}
|
||||
|
||||
splash_screen_text: {{ splash_screen_text }}
|
||||
|
||||
Uppercase Example: {{ 2 | foobar }}
|
||||
|
||||
get_pyproject: {{ get_pyproject("tool.flet") }}
|
||||
*/
|
||||
|
||||
{% for dep in cookiecutter.flutter.dependencies %}
|
||||
|
|
|
|||
Loading…
Reference in New Issue