### Start Frappe Server Source: https://github.com/waishnav/frappe/blob/develop/README.md Starts the Frappe development server. This command is essential for running the Frappe framework locally. ```Shell bench start ``` -------------------------------- ### Frappe Installation Hooks Source: https://github.com/waishnav/frappe/blob/develop/hooks.md Specifies methods to be executed before and after the application installation process. ```python before_install = "path.to.before_install_method" after_install = "path.to.after_install_method" ``` -------------------------------- ### Docker Setup for Frappe Source: https://github.com/waishnav/frappe/blob/develop/README.md This snippet demonstrates how to set up Frappe using Docker. It requires Docker, Docker Compose, and Git. After cloning the repository and running the compose command, the Frappe site will be accessible on localhost port 8080. ```Shell git clone https://github.com/frappe/frappe_docker cd frappe_docker docker compose -f pwd.yml up -d ``` -------------------------------- ### Misc Query Example Source: https://github.com/waishnav/frappe/blob/develop/frappe/query_builder/docs.md Shows how to use a list-based filter for querying, supporting various filter notations and implicit joins. ```python frappe.db.get_values("ToDo", fieldname="name", filters=["description", "=", "someone"]) ``` -------------------------------- ### Criterion Query Example Source: https://github.com/waishnav/frappe/blob/develop/frappe/query_builder/docs.md Illustrates using inherent query builder objects and pypika filters for constructing queries. ```python from frappe.query_builder import Field frappe.db.get_values("User", fieldname="name", filters=Field("name") == "Administrator") ``` -------------------------------- ### Frappe: Setup Tags Source: https://github.com/waishnav/frappe/blob/develop/frappe/patches.txt Initializes or configures the tagging system within Frappe. This patch enables users to categorize and organize records using tags. ```python frappe.patches.v12_0.setup_tags ``` -------------------------------- ### Run Frappe Tests Programmatically Source: https://github.com/waishnav/frappe/blob/develop/frappe/testing/README.md This example demonstrates how to programmatically configure and run tests in Frappe applications using the TestConfig and TestRunner classes. It discovers all tests within specified applications and then executes them. ```Python from frappe.testing import TestConfig, TestRunner, discover_all_tests config = TestConfig(failfast=True, verbose=2) runner = TestRunner(cfg=config) discover_all_tests(['my_app'], runner) runner.run() ``` -------------------------------- ### Execute Frappe Get Role Save Source: https://github.com/waishnav/frappe/blob/develop/frappe/patches.txt This snippet demonstrates fetching a 'Guest' role document and saving it, likely to apply default settings or ensure its presence in the system. ```python execute:frappe.get_doc('Role', 'Guest').save() # remove desk access ``` -------------------------------- ### Dict Query Example Source: https://github.com/waishnav/frappe/blob/develop/frappe/query_builder/docs.md Demonstrates fetching values using a dictionary-based filter, including support for like and in operators. ```python frappe.db.get_values("ToDo", fieldname="name", filters={"description": "Something Random"}) ``` ```python frappe.db.get_values("User", fieldname="name", filters={"name": ("like", "admin%")}) ``` ```python frappe.db.get_values("ToDo", fieldname="name", filters={"description": ("in", ["somso%", "someome"])}) ``` -------------------------------- ### Show config in bench CLI (Frappe) Source: https://github.com/waishnav/frappe/blob/develop/frappe/change_log/v13/v13_3_0.md Introduces the ability to display configuration details using the `bench` CLI in Frappe. This command allows users to view their current Frappe environment settings, aiding in troubleshooting and understanding the setup. ```Python bench config show ``` -------------------------------- ### Frappe Template Inclusion Source: https://github.com/waishnav/frappe/blob/develop/frappe/www/app.html Includes external HTML templates within the main template. This example shows the inclusion of a splash screen and Google Analytics template. ```HTML {% include "templates/includes/splash_screen.html" %} {% include "templates/includes/app_analytics/google_analytics.html" %} ``` -------------------------------- ### Frappe: Setup Comments from Communications Source: https://github.com/waishnav/frappe/blob/develop/frappe/patches.txt Migrates or sets up comment data by leveraging existing communication records. This patch integrates communication history with comment features. ```python frappe.patches.v12_0.setup_comments_from_communications ``` -------------------------------- ### Frappe App Interaction JavaScript Source: https://github.com/waishnav/frappe/blob/develop/frappe/www/apps.html This JavaScript code handles user interactions within the Frappe application. It includes functions to set an app as default, retrieve incomplete setup routes, and log out the user, utilizing Frappe's client-side API for making calls to the server. ```javascript $('.set-default').on('click', function (e) { e.preventDefault(); var appName = $(this).attr('app-name'); frappe.call({ method: "frappe.apps.set_app_as_default", args: { app_name: appName }, callback: function () { location.reload(); }, }); }); $('.app-name-cls').on('click', function (e) { localStorage.current_app = $(this).attr('app-name'); localStorage.current_route = $(this).attr('app-route'); frappe.call({ method: "frappe.apps.get_incomplete_setup_route", args: { current_app: localStorage.current_app, app_route: localStorage.current_route }, callback: function (r) { window.location.href = r.message; } }) }); $('.logout-btn').on('click', function () { localStorage.current_app = ""; localStorage.current_route = ""; frappe.call({ method: "logout", callback: function () { window.location.href = "/login"; }, }); }); ``` -------------------------------- ### Conditional UI Rendering in Frappe Source: https://github.com/waishnav/frappe/blob/develop/frappe/public/js/frappe/form/templates/form_sidebar.html Demonstrates how to conditionally render UI elements in Frappe templates based on user permissions (can_write) and feature flags (frm.meta.beta). Includes examples for displaying 'Change', 'Upload', 'Remove', and 'Report bug' links. ```Jinja {% if can_write %} [{{ __("Change") }}](#) {{ __("Upload") }} {{ __("Remove") }} {% endif %} {% if frm.meta.beta %} {{ __("Experimental") }} [{{ __("Report bug") }}](https://github.com/frappe/{{ frappe.boot.module_app[frappe.scrub(frm.meta.module)] }}/issues/new) {% endif %} ``` -------------------------------- ### Create and Map Frappe Site Source: https://github.com/waishnav/frappe/blob/develop/README.md Creates a new Frappe site and maps it to the local host. This involves creating a new site instance and configuring host entries for local access. ```Shell # Create a new site bench new-site frappe.dev # Map your site to localhost bench --site frappe.dev add-to-hosts ``` -------------------------------- ### Frappe: Update Genders Using Install Fixtures Source: https://github.com/waishnav/frappe/blob/develop/frappe/patches.txt Updates gender data by calling a function from the install fixtures module. This patch ensures accurate gender information is available. ```python execute:from frappe.desk.page.setup_wizard.install_fixtures import update_genders;update_genders() ``` -------------------------------- ### Frappe Initialization and Bootstrapping Source: https://github.com/waishnav/frappe/blob/develop/frappe/www/app.html Initializes the Frappe application in the browser by setting version numbers, enabling development server mode, loading boot data, and configuring CSRF tokens. It also includes placeholders for CSS, JavaScript, and icon assets. ```JavaScript window._version_number = "{{ build_version }}"; // browser support window.app = true; window.dev_server = {{ dev_server }}; if (!window.frappe) window.frappe = {}; frappe.boot = {{ boot | json }}; frappe._messages = frappe.boot["__messages"]; frappe.csrf_token = "{{ csrf_token }}"; ``` -------------------------------- ### Frappe Client-Side Initialization (JavaScript) Source: https://github.com/waishnav/frappe/blob/develop/frappe/website/doctype/web_form/templates/web_list.html This JavaScript snippet initializes Frappe's client-side environment. It sets global variables for boot data, translated messages, and web form documents, and includes the 'web_form.bundle.js' script for form functionality. ```JavaScript frappe.boot = {{ boot | json }}; frappe._messages = {{ translated_messages }}; frappe.web_form_doc = {{ web_form_doc | json }}; {{ include_script("web_form.bundle.js") }} ``` -------------------------------- ### Frappe Web Bundle Inclusion Source: https://github.com/waishnav/frappe/blob/develop/frappe/templates/base.html Includes the main Frappe web bundle JavaScript file and sets system defaults from the boot object for backward compatibility. ```JavaScript frappe.boot = {{ boot | json }}; // for backward compatibility of some libs frappe.sys_defaults = frappe.boot.sysdefaults; {{ include_script('frappe-web.bundle.js') }} ``` -------------------------------- ### Frappe: Remove Example Email Thread Notify Source: https://github.com/waishnav/frappe/blob/develop/frappe/patches.txt Removes or disables the 'example_email_thread_notify' functionality. This patch cleans up or deprecates a specific email notification feature. ```python frappe.patches.v12_0.remove_example_email_thread_notify ``` -------------------------------- ### Frappe Search Initialization and Footer Styling Source: https://github.com/waishnav/frappe/blob/develop/frappe/templates/doc.html This JavaScript code initializes the search functionality for Frappe applications using `frappe.ready`. It also modifies the footer's container classes to enhance responsiveness and styling on documentation pages. ```javascript frappe.ready(() => { frappe.setup_search('#search-container', '{{ docs_search_scope or "" }}'); $('.web-footer .container') .removeClass('container') .addClass('container-fluid doc-container'); }); ``` -------------------------------- ### Displaying Changed Values in Frappe Source: https://github.com/waishnav/frappe/blob/develop/frappe/core/doctype/version/version_view.html This snippet shows how to iterate through changed values, displaying the property, original value, and new value. It uses Frappe's meta and utility functions for getting labels and escaping HTML. ```HTML {% if data.changed && data.changed.length %} #### {{ __("Values Changed") }} {% for item in data.changed %} {% endfor %} {{ __("Property") }} {{ __("Original Value") }} {{ __("New Value") }} {{ frappe.meta.get_label(doc.ref_doctype, item[0]) }} {{ frappe.utils.escape_html(item[1]) }} {{ frappe.utils.escape_html(item[2]) }} {% endif %} ``` -------------------------------- ### Frappe JavaScript Initialization Source: https://github.com/waishnav/frappe/blob/develop/frappe/templates/base.html Initializes the Frappe JavaScript object and sets global variables for application configuration, including version number, development server status, socketIO port, and language picker visibility. ```JavaScript window.frappe = {}; window._version_number = "{{ build_version }}"; frappe.ready_events = []; frappe.ready = function(fn) { frappe.ready_events.push(fn); } window.dev_server = {{ dev_server }}; window.socketio_port = {{ (frappe.socketio_port or 9000) }}; window.show_language_picker = {{ show_language_picker or 'false' }}; ``` -------------------------------- ### Frappe Template Rendering and Includes Source: https://github.com/waishnav/frappe/blob/develop/frappe/templates/base.html Renders various HTML blocks and includes template files for different parts of the Frappe web interface, such as meta information, title, head, navbar, and footer. ```HTML {% block meta_block %} {% include "templates/includes/meta_block.html" %} {% endblock %} {% block title %}{{ title | striptags }}{% endblock %} {% block favicon %} {% endblock %} {%- block head -%} {% include "templates/includes/head.html" %} {%- endblock -%} {%- block head_include %} {{ head_include or "" }} {% endblock -%} {%- block style %} {% if colocated_css -%} {{ colocated_css }} {%- endif %} {% endblock -%} {%- block banner -%} {% include "templates/includes/banner_extension.html" ignore missing %} {% if banner_html -%} {{ banner_html or "" }} {%- endif %} {%- endblock -%} {%- block navbar -%} {{ web_block( navbar_template or 'StandardNavbar', values=_context_dict, add_container=0, add_top_padding=0, add_bottom_padding=0, ) }} {%- endblock -%} {% block content %} {{ content }} {% endblock %} {%- block footer -%} {{ web_block( footer_template or 'Standard Footer', values=_context_dict, add_container=0, add_top_padding=0, add_bottom_padding=0 ) }} {%- endblock -%} ``` -------------------------------- ### JavaScript User Feedback Handler Source: https://github.com/waishnav/frappe/blob/develop/frappe/website/doctype/help_article/templates/help_article.html This JavaScript code initializes on page load using frappe.ready. It attaches click event listeners to elements with the class 'feedback' to handle user feedback on help articles. It makes a server call to update feedback status and updates the UI accordingly. ```JavaScript frappe.ready(function() { frappe.set_search_path("/kb"); $(".feedback").click(function() { let args = { article: "{{ reference_name or name }}", helpful: this.getAttribute("data-value"), } frappe.call({ btn: this, method: "frappe.website.doctype.help_article.help_article.add_feedback", args: args, callback: function(r) { $(".feedback")[0].classList.add("hidden"); $(".feedback")[1].classList.add("hidden"); $(".feedback-msg")[0].classList.remove("hidden"); } }) }); }); ``` -------------------------------- ### Get Alignment Class in Frappe Source: https://github.com/waishnav/frappe/blob/develop/frappe/templates/print_formats/standard_macros.html Determines the CSS text alignment class for a field based on its type and alignment settings. It applies specific classes for right-aligned numeric fields and center-aligned checkboxes, with a fallback for general text alignment. ```Jinja {%- macro get_align_class(df, no_of_cols=2) -%} {% if no_of_cols >= 3 %}{{ "" }} {%- elif df.align -%}{{ "text-" + df.align }} {%- elif df.fieldtype in ("Int", "Float", "Currency", "Percent") -%}{{ "text-right" }} {%- elif df.fieldtype in ("Check",) -%}{{ "text-center" }} {%- else -%}{{ "" }} {% endif -%} {%- endmacro -%} ``` -------------------------------- ### Frappe Language-Specific Initialization (Esperanto) Source: https://github.com/waishnav/frappe/blob/develop/frappe/www/app.html Initializes language-specific variables for Esperanto ('eo'). It sets up an array `_jipt` and pushes project information into it. ```JavaScript {% if lang == "eo" %} var _jipt = []; _jipt.push(['project', 'frappe']); {% endif %} ``` -------------------------------- ### Displaying Help and User Information in Frappe Source: https://github.com/waishnav/frappe/blob/develop/frappe/public/js/frappe/form/templates/form_sidebar.html Shows how to display user-centric information and actions within Frappe templates. This includes 'Feedback', 'Help' (conditionally available), 'Assigned To', 'Attachments', 'Show All', 'Tags', 'Share', and follow/unfollow actions. ```Jinja {%= __("Feedback") %} {% if (frappe.help.has_help(doctype)) { %} {{ __("Help") }} {% } %} {%= __("Assigned To") %} {%= __("Attachments") %} {%= __("Show All") %} {%= __("Tags") %} {%= __("Share") %} {%= __("Followed by") %} {%= __("Follow") %} {%= __("Unfollow") %} ``` -------------------------------- ### Frappe Jinja: Render Table Macro Source: https://github.com/waishnav/frappe/blob/develop/frappe/templates/print_formats/standard_macros.html The `render_table` macro is responsible for rendering table fields in Frappe documents. It retrieves table metadata, filters data based on start and end indices, and iterates through visible columns to display data. It also supports custom child print templates for enhanced formatting. ```Jinja {% macro render_table(df, doc) -%} {%- set table_meta = frappe.get_meta(df.options) -%} {%- set data = doc.get(df.fieldname)[df.start:df.end] -%} {%- if doc.print_templates and doc.print_templates.get(df.fieldname) -%} {% include doc.print_templates[df.fieldname] %} {%- else -%} {%- if data -%} {%- set visible_columns = get_visible_columns(doc.get(df.fieldname), table_meta, df) -%} {% for tdf in visible_columns %} {% endfor %} {% for d in data %} {% for tdf in visible_columns %} {% else %} {{ _("Sr") }} {{ _(tdf.label) }} {{ d.idx }} {% if doc.child_print_templates %} {%- set child_templates = doc.child_print_templates.get(df.fieldname) -%} {{ _(print_value(tdf, d, doc, visible_columns, child_templates)) }} {%- endif -%} {% endif %} {% endfor %} {% endfor %} {{ _(print_value(tdf, d, doc, visible_columns)) }} {%- endif -%} {%- endmacro -%} ``` -------------------------------- ### Help Menu Rendering Source: https://github.com/waishnav/frappe/blob/develop/frappe/public/js/frappe/ui/toolbar/navbar.html This code iterates through a list of help menu items (`navbar_settings.help_dropdown`) and renders them. It supports navigation via routes or actions, and hides items based on a 'hidden' property. ```HTML {% for item in navbar_settings.help_dropdown %} {% if (!item.hidden) { %} {% if (item.route) { %} {{ __("item.item_label") }} {% } else if (item.action) { %} {{ __("item.item_label") }} {% } {% } {% } {% endfor %} ``` -------------------------------- ### Frappe Blog Content Rendering Source: https://github.com/waishnav/frappe/blob/develop/frappe/website/doctype/blog_post/templates/blog_post.html This snippet demonstrates how to render blog post content within a Frappe template. It includes displaying the title, introduction, publication date, read time, and the main blog content. It also shows how to format dates using Frappe's utility functions. ```html {{ title }} ========== {{ blog_intro }} {{ frappe.format_date(published_on) }} {%- if read_time -%} · {{ read_time }} {{ _('min read') }} {%- endif -%} {{ content }} ``` -------------------------------- ### Fetch and Display Discussion Topics (Jinja) Source: https://github.com/waishnav/frappe/blob/develop/frappe/templates/discussions/discussions_section.html Fetches all discussion topics related to a specific doctype and docname using Frappe's `get_all` method. It then conditionally renders UI elements like topic modals, search bars, and buttons based on the number of topics and whether it's a single thread view. Includes logic for displaying replies and an empty state. ```Jinja {% set topics = frappe.get_all("Discussion Topic", {"reference_doctype": doctype, "reference_docname": docname}, ["name", "title", "owner", "creation"]) %} {% if not single_thread %} {% include "frappe/templates/discussions/topic_modal.html" %} {% endif %} {{ _(title) }} {% if topics | length and not single_thread %} {% include "frappe/templates/discussions/search.html" %} {% endif %} {% if topics and not single_thread %} {% include "frappe/templates/discussions/button.html" %} {% endif %} {% if topics and not single_thread %} {% for topic in topics %} {% set replies = frappe.get_all("Discussion Reply", {"topic": topic.name})%} {% include "frappe/templates/discussions/sidebar.html" %} {% if loop.index != topics | length %} {% endif %} {% endfor %} {% for topic in topics %} {% include "frappe/templates/discussions/reply_section.html" %} {% endfor %} {% elif single_thread %} {% set topic = topics[0] if topics | length else None %} {% include "frappe/templates/discussions/reply_section.html" %} {% else %}  {{ empty_state_title }} {{ empty_state_subtitle }} {% if frappe.session.user == "Guest" %} {{ _("Login") }} {% elif condition is defined and not condition %} {{ button_name }} {% else %} {% include "frappe/templates/discussions/button.html" %} {% endif %} {% endif %} ``` -------------------------------- ### Execute Frappe Call System Settings Sync Source: https://github.com/waishnav/frappe/blob/develop/frappe/patches.txt This snippet executes a Frappe framework call to synchronize system settings, ensuring that all configurations are up-to-date and applied correctly. ```python execute:frappe.call("frappe.core.doctype.system_settings.system_settings.sync_system_settings") ``` -------------------------------- ### Frappe Web Template for QR Code Verification Source: https://github.com/waishnav/frappe/blob/develop/frappe/www/qrcode.html This snippet represents a Frappe web template (`.html`) that extends a base web template. It defines the page title and the main content area, which includes a heading for QR Code login verification, a personalized greeting, step-by-step instructions for the user, a list of supported authentication apps, and an embedded QR code generated from SVG data. ```html {% extends "templates/web.html" %} {% block title %}{{ \_("QR Code") }}{% endblock %} {% block page_content %} {{ \_("QR Code for Login Verification") }} ========================================== {{ \_("Hi {0}").format(qr_code_user.first_name) }}, {{ \_("Steps to verify your login") }}: 1. {{ \_("Open your authentication app on your mobile phone.") }} 2. {{ \_("Scan the QR Code and enter the resulting code displayed.") }} 3. {{ \_("Return to the Verification screen and enter the code displayed by your authentication app") }} {{ \_("Authentication Apps you can use are: ") }} FreeOTP, Google Authenticator, Lastpass Authenticator, Authy and Duo Mobile.  {% endblock %} ``` -------------------------------- ### Frappe Dynamic JavaScript Includes Source: https://github.com/waishnav/frappe/blob/develop/frappe/templates/base.html Includes additional JavaScript files dynamically based on project configuration, such as icons and other specified scripts. ```JavaScript {%- for path in web_include_icons -%} {{ include_icons(path) }} {%- endfor -%} {%- for link in web_include_js %} {{ include_script(link) }} {%- endfor -%} ``` -------------------------------- ### Frappe: Rename Onboarding Source: https://github.com/waishnav/frappe/blob/develop/frappe/patches.txt Renames elements or configurations related to the onboarding process. This patch standardizes naming for user onboarding flows. ```python frappe.patches.v13_0.rename_onboarding ``` -------------------------------- ### Jinja for Styles and Content Source: https://github.com/waishnav/frappe/blob/develop/frappe/templates/print_formats/pdf_header_footer.html Jinja templating loops to dynamically include styles and content. It iterates through `styles` and `content` variables, rendering them as strings within the template. ```jinja {% for tag in styles -%} {{ tag | string }} {%- endfor %} {% for tag in content -%} {{ tag | string }} {%- endfor %} ``` -------------------------------- ### Frappe Client-Side Initialization Source: https://github.com/waishnav/frappe/blob/develop/frappe/www/message.html This JavaScript snippet initializes Frappe functionality on page load. It sets the last session route in local storage if the URL contains a hash or '/app', and focuses the primary button. ```JavaScript frappe.ready(function() { if (window.location.hash || window.location.href.includes('/app')) { localStorage.setItem('session_last_route', window.location.pathname); } $('.btn-primary').focus(); }); ``` -------------------------------- ### Frappe Asset Inclusion (Icons) Source: https://github.com/waishnav/frappe/blob/develop/frappe/www/app.html Includes icon assets for the Frappe application. It iterates through a list of icon paths and applies them using the `include_icons` function. ```HTML {%- for path in app_include_icons -%} {{ include_icons(path) }} {%- endfor -%} ``` -------------------------------- ### Frappe Asset Inclusion (CSS) Source: https://github.com/waishnav/frappe/blob/develop/frappe/www/app.html Includes CSS assets for the Frappe application. It iterates through a list of CSS includes and applies them using the `include_style` function. ```HTML {% for include in app_include_css -%} {{ include_style(include) }} {%- endfor -%} ``` -------------------------------- ### Frappe Attribution Template Source: https://github.com/waishnav/frappe/blob/develop/frappe/www/attribution.html This Jinja template renders the attribution page for the Frappe framework. It iterates through a list of applications and their associated open source packages, displaying names, authors, descriptions, and dependencies. It also includes placeholders for package type and license. ```Jinja {% extends "templates/web.html" %} {% block head_include %} {% endblock %} {% block page_content %} {{ _("Attribution") }} ======================= {{ _("This software is built on top of many open source packages.") }} {{ _("We would like to thank the authors of these packages for their contribution.") }} {% for app_info in apps %} [{{ app_info.name }}](#{{ app_info.name }}) -------------------------------------------- {% if app_info["dependencies"] %} {% endif %} {{ _("Authors") }} {{ app_info.authors }} {{ _("Description") }} {{ app_info.description }} {{ _("Dependencies") }} {% for package in app_info["dependencies"] %} {% endfor %} {{ _("Package") }} {{ _("Type") }} {{ _("License") }} {{ _("Authors / Maintainers") }} {{ package.name | e }} {{ package.type }} {{ package.license or "Unknown" }} {{ package.author or "Unknown" }} {% endfor %} {% endblock %} ``` -------------------------------- ### Frappe Require Async Loading (JavaScript) Source: https://github.com/waishnav/frappe/blob/develop/frappe/change_log/v7/v7_0_0.md Demonstrates the asynchronous loading capability of frappe.require, which is a change from its previous behavior. This allows for more efficient loading of JavaScript resources. ```JavaScript frappe.require("custom_script.js", function() { // Callback function after the script is loaded console.log("custom_script.js loaded asynchronously"); }); ``` -------------------------------- ### Format list-apps in bench CLI (Frappe) Source: https://github.com/waishnav/frappe/blob/develop/frappe/change_log/v13/v13_3_0.md Introduces a format option for the list-apps command in the Frappe bench CLI, allowing for more flexible output of application information. This enhancement improves the usability of the command-line interface for managing Frappe applications. ```Python bench --format list-apps ``` -------------------------------- ### Frappe Base Template Structure (HTML/Jinja) Source: https://github.com/waishnav/frappe/blob/develop/frappe/www/apps.html This snippet shows the basic HTML structure of a Frappe template using Jinja2 syntax. It defines blocks for the navbar, footer, content, and scripts, allowing for modular content inclusion and extension. ```jinja {%- block navbar -%} {% from "frappe/templates/includes/avatar_macro.html" import avatar %} {%- endblock -%} {%- block footer -%} {%- endblock -%} {% block content %} {{ _('Select an app to continue') }} {% set appsCount = apps|length if apps|length <= 6 else 6 %} {% for app in apps %}  {{ app.title }} {% endfor %} {{ _('Logout') }} {% endblock %} {% block script %} ``` -------------------------------- ### Load Heap Analytics with Jinja and JavaScript Source: https://github.com/waishnav/frappe/blob/develop/frappe/templates/includes/app_analytics/heap_analytics.html This snippet demonstrates how to conditionally load the Heap Analytics JavaScript SDK using Jinja templating and JavaScript. It ensures that the Heap script is only loaded if a `heap_analytics_id` is provided. The script is configured for SSL and includes standard Heap tracking functions. ```Jinja {% if heap_analytics_id %} window.heap=window.heap||[],heap.load=function(e,t){window.heap.appid=e,window.heap.config=t=t||{};var r=t.forceSSL||"https:"===document.location.protocol,a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src=(r?"https:" :"http:")+"//cdn.heapanalytics.com/js/heap-"+e+".js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n);for(var o=function(e){return function(){heap.push([e].concat(Array.prototype.slice.call(arguments,0)))}},p=["addEventProperties","addUserProperties","clearEventProperties","identify","removeEventProperty","setEventProperties","track","unsetEventProperty"],c=0;c